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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—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.