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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 748 views
  • 0 likes
  • 4 in conversation