## Identify first and subsequent data value in rows

Solved
Frequent Contributor
Posts: 81

# Identify first and subsequent data value in rows

Hi,

I need help with creating a flag whenever there is the first occurrence of value >180, and order the subsequent values that are >18

Have:

 id date Value 1 First_date 113 2 next_2 97 3 next_3 86 4 next_4 138 5 next_5 193 6 next_6 90 7 next_7 197

want:

 id date Value Flag > 180 values in that order 1 First_date 113 0 2 next_2 97 0 3 next_3 86 0 4 next_4 138 0 5 next_5 193 1 6 next_6 90 0 7 next_7 197 2

Thank you, I will appreciate your help.

Accepted Solutions
Solution
‎04-07-2018 12:30 AM
PROC Star
Posts: 8,150

## Re: Identify first and subsequent data value in rows

Here is one way:

```data want (drop=counter);
set have;
if value gt 180 then counter+1;
flag=ifn(value gt 180,counter,0);
run;
```

Art, CEO, AnalystFinder.com

All Replies
Solution
‎04-07-2018 12:30 AM
PROC Star
Posts: 8,150

## Re: Identify first and subsequent data value in rows

Here is one way:

```data want (drop=counter);
set have;
if value gt 180 then counter+1;
flag=ifn(value gt 180,counter,0);
run;
```

Art, CEO, AnalystFinder.com

Frequent Contributor
Posts: 81

## Re: Identify first and subsequent data value in rows

Thank you so much, it worked!!!!
☑ This topic is solved.