BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
ead=cats('z',level_1,level_2,level_4,level_6);

what does this do?

5 REPLIES 5
CalebSindi
SAS Employee

It concatenates the string 'z' with the strings listed in the columns that are specified as arguments. It removes leading and trailing blanks before concatenation, I think.

MaggyShiks
Calcite | Level 5
In SAS, the code ead=cats('z', level_1, level_2, level_4, level_6); is using the CATS function to concatenate several variables and a string into a single character variable called "ead".

Here's what each component of the code does:

cats('z', level_1, level_2, level_4, level_6): This is the CATS function, which concatenates multiple arguments into a single character value. In this case, it concatenates the string 'z' with the values of the variables level_1, level_2, level_4, and level_6.

ead=: This assigns the concatenated value to the character variable "ead".

The resulting value of "ead" will be a string that combines the values of the variables level_1, level_2, level_4, and level_6, with 'z' appended at the beginning.

For example, if level_1 = 'A', level_2 = 'B', level_4 = 'C', and level_6 = 'D', the resulting value of "ead" would be 'zABCD'. The values of the variables are concatenated together, with 'z' added at the beginning.

Note that the CATS function removes leading and trailing spaces from the values it concatenates. If you want to preserve the spaces, you can use the CATX function instead.
ballardw
Super User

@HeatherNewton wrote:
ead=cats('z',level_1,level_2,level_4,level_6);

what does this do?


<Pedantic mode: on>

Since it is not part of a data step or other procedure that allows such code it does nothing and probably throws an error.

</Pedantic mode: off>

 

Have you tried placing the cursor in the SAS editor on the function, such as CATS, and pressing F1? Does anything happen?

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 160 views
  • 0 likes
  • 5 in conversation