BookmarkSubscribeRSS Feed
Xiaoyi
Obsidian | Level 7

Concatenate multiple column and add space

I want to concatenate multiple column to a new var as show below, adding space and other signs. I wrote a very long and a little complicated catx with many layers.

I wonder if you have a more straight forward and much simpler way to do this. Thank you in advance.

Obs count prev CI_L CI_H Newvar
1 22 1.2 0.7 1.8 1.2 (0.7-1.8)
2 66 3.5 2.7 4.4 3.5 (2.7-4.4)
3 121 6.4 5.3 7.6 6.4 (5.3-7.6)
2 REPLIES 2
Xiaoyi
Obsidian | Level 7

I think I figure out a simpler method using catx and cats. But if you have any other ideas, feel free to post and help whoever may look for an answer for the same question. Thanks.

Tom
Super User Tom
Super User

If the source variables are numeric then you probably also want to use PUT() rather than just CATS() to convert them into strings.  That will make sure the strings used to represent the numbers use consistent style.  

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 633 views
  • 0 likes
  • 2 in conversation