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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.