New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Lapis Lazuli | Level 10
Hi, how can I add suffix to Ids based on a column?
Suppose to have:
Id suffix
0001 1
0001 1
0001 2
0002 2
0002 2
0002 1

Desired output
Id
0001_1
0001_1
0001_2
0002_2
0002_2
0002_1

Thank you in advance
1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
Kurt_Bremser
Super User

Most probably, you need to define a new variable (because of the length):

data want;
set have (rename=(id=_id)),
length id $6;
id = catx("_",_id,suffix);
drop _id suffix;
run;
NewUsrStat
Lapis Lazuli | Level 10
Thank you dottor bremser. It works perfectly. Only one question: is it possible to convert back the modified ID to numeric?
NewUsrStat
Lapis Lazuli | Level 10
ok thank you! It is just because there is a piece of code downstream that looks at it as numeric.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 796 views
  • 3 likes
  • 2 in conversation