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!
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;
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;
Thanks so much!! This is exactly what I was looking for !
you are welcome.
glad it was a simple issue to resolve.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.