SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

how to get the first high values in a row by group

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

how to get the first high values in a row by group

[ Edited ]

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.  


Accepted Solutions
Solution
‎06-28-2018 06:08 PM
Super User
Posts: 2,073

Re: how to get the first high values in a row by group

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


All Replies
Solution
‎06-28-2018 06:08 PM
Super User
Posts: 2,073

Re: how to get the first high values in a row by group

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;
Contributor
Posts: 50

Re: how to get the first high values in a row by group

Posted in reply to novinosrin
Thank you so much for the help.
Super User
Posts: 2,073

Re: how to get the first high values in a row by group

You are welcome Smiley Happy Have a good one!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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