BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AZIQ1
Quartz | Level 8

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:

iddateValue
1First_date113
2next_297
3next_386
4next_4138
5next_5193
6next_690
7next_7197

want:

 

iddateValueFlag > 180 values in that order
1First_date1130
2next_2970
3next_3860
4next_41380
5next_51931
6next_6900
7next_71972

Thank you, I will appreciate your help.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

 

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

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

 

AZIQ1
Quartz | Level 8
Thank you so much, it worked!!!!

sas-innovate-2024.png

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.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 2 replies
  • 790 views
  • 1 like
  • 2 in conversation