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.
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
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
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.
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.