BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

I have following dataset and I am trying to concat. percent formatted to 9.1 (already did that) 

 

idfreqpercent
1133.3
2111.1
3125

 

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:

 

idfreqpercentcombine
1133.31(33.3333333%)
2111.11(11.1111111%)
31251(25.0000000%)
2 REPLIES 2
Kurt_Bremser
Super User

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))
ChrisNZ
Tourmaline | Level 20
Or
catx(' ',freq,'('!!put(percent/100,percent7.1)!!')')

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
  • 923 views
  • 1 like
  • 3 in conversation