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) |
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.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.