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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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