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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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