BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shasank
Quartz | Level 8

Hello SAS community,

 

I would like your help in the following problem.

 

raw data:-

 

IDseqIdnum
10001
10205
10304
10405
20001
20301
30001
   

  

I would like to recode 00 as 01 when the subsequent code under same ID are >00 and keep the 00 when there are no subsequent codes.

 

The output can look like this.

IDseqIdnum
10101
10205
10304
10405
20101
20301
30001


Thank you for your help.  

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input ID	(seq	Idnum) ($);
cards;
1	00	01
1	02	05
1	03	04
1	04	05
2	00	01
2	03	01
3	00	01
;

data want;
set have;
by id;
if first.id and not last.id then seq='01';
run;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data have;
input ID	(seq	Idnum) ($);
cards;
1	00	01
1	02	05
1	03	04
1	04	05
2	00	01
2	03	01
3	00	01
;

data want;
set have;
by id;
if first.id and not last.id then seq='01';
run;
shasank
Quartz | Level 8
Thank you so much for the help.
novinosrin
Tourmaline | Level 20

You are welcome 🙂 Have a good one!

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!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 787 views
  • 0 likes
  • 2 in conversation