Solved
Contributor
Posts: 50

# 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:-

 ID seq Idnum 1 00 01 1 02 05 1 03 04 1 04 05 2 00 01 2 03 01 3 00 01

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.

 ID seq Idnum 1 01 01 1 02 05 1 03 04 1 04 05 2 01 01 2 03 01 3 00 01

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;``````

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

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 Have a good one!

☑ This topic is solved.