BookmarkSubscribeRSS Feed
HBSU
Calcite | Level 5

I need to create a new variable that categorizes survey responses (n=5 items, scored from 0-100) into three categories based on the number of responses that fall in a certain numerical range. I.e. if at least 3 scores fall into the 0-33 range, then the category in the new variable should equal L (where L means Languishing). If at least 3 scores fall into the 66-100, then the category in the new variable should equal F (where F means Flourishing). Else, new categorical variable should equal M (where M means Moderate).

 

The table below illustrates the type of data I'm working with. 

 

IDVar1Var2Var3Var4Var5
12278567798
2120225563
3882873073
4149558745
51566539654
1 REPLY 1
Reeza
Super User
Try the following:

if largest(3, of var1-var5) >= 66 then category = "F";
else if largest(3, of var1-var5) <= 33 then category = "L";
else category = "M";

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 771 views
  • 5 likes
  • 2 in conversation