I have following dataset and I am trying to concat. percent formatted to 9.1 (already did that)
id | freq | percent |
1 | 1 | 33.3 |
2 | 1 | 11.1 |
3 | 1 | 25 |
But when I use this one below:
combine = cats(freq, ' ', '(', percent, '%)')
There is 1) no space between freq and percent and all my percent numbers are super long , like this:
id | freq | percent | combine |
1 | 1 | 33.3 | 1(33.3333333%) |
2 | 1 | 11.1 | 1(11.1111111%) |
3 | 1 | 25 | 1(25.0000000%) |
Maxim 1: Read the Documentation.
Cats() strips values before concatenating, so the blank vanishes. Use catx() instead.
And the implicit type conversion numeric to character uses a best. format, causing the long numbers.
Also use the percent. format:
catx(' ',freq,put(percent/100,percent7.1))
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.