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

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!

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