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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 755 views
  • 0 likes
  • 4 in conversation