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

Hello! I am a novice user and have looked through the forum for hours trying to find a solution to this problem to no avail. 

 

I have survey health data for over 200,000 individuals (each row represents a unique individual) and I would like to create a simple comorbidity index. I have 9 variables (columns) representing 9 medical conditions (all binary numeric, coded as 0 = no and 1 = yes), and would like to create a new variable which tells me how many individuals report having 0, 1, 2, 3 or 4 or more medical conditions. 

 

I'm sorry I don't know how to add a sample of the data! This is as far as I've gotten - creating a new variable that is able to indicate that a person has all 9 comorbid diseases, or none of the 9 diseases. I'm stuck at being able to indicate if they have three of the 9 diseases, how to indicate comorbid = 3, and if they have any two of the 9 diseases, how to indicate comorbid = 2, etc.... 

 

DATA CP;
SET M.CP; 
COMORBID = .;
IF (EVER_ASTHMA = 1) AND (EVER_EMPHYS =1) AND (EVER_CB =1) AND (EVER_DIAB=1) AND (EVER_TB=1) AND (EVER_HD=1) AND (EVER_MIOC=1) AND (EVER_RESP=1) AND (EVER_HBP=1) THEN COMORBID = 9;
IF (EVER_ASTHMA = 0) AND (EVER_EMPHYS =0) AND (EVER_CB =0) AND (EVER_DIAB=0) AND (EVER_TB=0) AND (EVER_HD=0) AND (EVER_MIOC=0) AND (EVER_RESP=0) AND (EVER_HBP=0) THEN COMORBID = 0;
RUN;

 

Thanks in advance! 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

are you looking for something like this

 


DATA CP;
SET M.CP; 
COMORBID = 0;
COMORBID = sum(EVER_ASTHMA, EVER_EMPHYS, EVER_CB, EVER_DIAB, EVER_TB, EVER_HD, EVER_MIOC, EVER_RESP, EVER_HBP);
run;

View solution in original post

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

are you looking for something like this

 


DATA CP;
SET M.CP; 
COMORBID = 0;
COMORBID = sum(EVER_ASTHMA, EVER_EMPHYS, EVER_CB, EVER_DIAB, EVER_TB, EVER_HD, EVER_MIOC, EVER_RESP, EVER_HBP);
run;
terra1
Calcite | Level 5

Thanks so much!! This is exactly what I was looking for ! 

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

you are welcome.

glad it was a simple issue to resolve.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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