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-wordmark-2025-midnight.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. Sign up by March 14 for just $795.


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
  • 1136 views
  • 0 likes
  • 2 in conversation