BookmarkSubscribeRSS Feed
shridula95
Calcite | Level 5

Hi

I am working on a 6 datasets and want to recode a particular variable from 1-9. Following this, I would like to create a new variable by adding up the values of the recoded variables. This variable is to be called K6SUM. Based on the K6SUM variable, I want to create a grouping variable called “SPD” as a binary variable. Any suggestions?

 

Thank you in advance:)

3 REPLIES 3
ballardw
Super User

Provide some example data and walk us through what you want.

How to create the recodes when we don't know the current variable type or values is pretty difficult.

Plus, since you are adding values of 1 through 9, apparently, then you can have sums all over place. So what would the rule be for creating a binary variable from those sums?

shridula95
Calcite | Level 5

I am working on NHIS data sets from 2010-2015. The variable is called Serious Psychological Disorder(SPD). It has data fields as follows-

SAD, NERVOUS, RESTLESS, HOPELESS, EFFORT, WORTHLS. These variables take on values from 1 through 9. The re-coding is to be done as follows-

1 - ALL of the time (recode as 4)
2 - MOST of the time (recode as 3)
3 - SOME of the time (recode as 2)
4 - A LITTLE of the time (recode as 1)
5 - NONE of the time (recode as 0)
7 – Refused (recode as missing)
8 - Not ascertained (recode as missing)
9 - Don't know (recode as missing)
Following this, I need to create a new variable called K6SUM by taking the sum of the re-coded values as specified above. Based on the K6SUM variable, I have to create a grouping variable called “Serous psychological distress” (SPD) as follows:
SPD = 1 IF K6SUM 13+
SPD = 0 IF K6SUM 0-12
SPD = . (MISSING). IF K6SUM=.(MISSING).

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
  • 3 replies
  • 1081 views
  • 0 likes
  • 3 in conversation