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.  

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
  • 2 replies
  • 744 views
  • 0 likes
  • 2 in conversation