BookmarkSubscribeRSS Feed
avama
Calcite | Level 5

Hello I have the following dataset but I am really stuck on how to do the hierarchy for few weeks actually. Any suggestions would be GREATLY appreciated!! Thank you!

 

Here are the rules:

If the group contains > 20 on any instance or then it should be code as 'TOO HIGH' or if it is between 16-20 TWICE in a row

If the group is between 11 through 15 twice in a row, then it should be 'HIGH' 

If the group is between 6 through 10 twice in a row, then it should be 'Low'

If the group is between 1 through 5 twice in a row, then it should be 'Normal'

 

Basically if the two consequentive events don't happen by top hierarchy (too high), you skip to the next level (high, low, normal, etc)

 

Here is the dataset

IDvalueseq_id
131
112
123
144
115
2201
2212
253
311
362
373
314
345
3216
3177
318
329
461
492
4123
4134
511
562
573
5144
5205
6111
6122
6253
6164
6215

 

 

Here's the output I am looking for:

 

IDvalueseq_idoutput
131Normal
112 
123 
144 
115 
2201Too High
2212 
253 
311 
362 
373 
314 
345 
3216Too High
3177 
318 
329 
461 
492 
4123High
4134 
511 
562Low
573 
5144 
5195 
6111 
6122 
6253Too High
6164 
6215

 

 

1 REPLY 1
FredrikE
Rhodochrosite | Level 12

What is the reason that you want to put the info on the first value of the 2?

 

If there are multiple rulestrue for the same ID, you only want the largest (too high-high-low-normal)?

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
  • 1 reply
  • 684 views
  • 0 likes
  • 2 in conversation