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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 784 views
  • 5 likes
  • 2 in conversation