BookmarkSubscribeRSS Feed
DavidD
Calcite | Level 5
I am in EG 4.2 and forgot how to combine a numeric and character string. Somebody sent me data with a three letter prefix in one column and the number suffix in another. What do i do to recombine II does not seem to work.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Explore using the various CAT-related functions in a DATA step.

Scott Barry
SBBWorks, Inc.
RichardH_sas
SAS Employee
If you're using PROC SQL code (and that means if you're writing an expression in the query builder too!!), just a warning that SAS won't do automatic conversion of numeric to character. You'd want a PUT function for that. There's a nice example here (PUT function is about 2/3 down the page):

http://support.sas.com/kb/35/315.html

Once a PUT function does the conversion work in the expression, you could use "||" as you suggest to conbine the strings. You could also use a function like CATS. Something like...

CATS(t1.prefix,PUT(t1.number,4.))
Patrick
Opal | Level 21
No need to use the inner put() with cats().
Cats() digests both character and numeric.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1465 views
  • 0 likes
  • 4 in conversation