## Creating simple comorbidity index

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; ```

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Creating simple comorbidity index

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;``````
3 REPLIES 3

## Re: Creating simple comorbidity index

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;``````

## Re: Creating simple comorbidity index

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

## Re: Creating simple comorbidity index

you are welcome.

glad it was a simple issue to resolve.

Discussion stats
• 3 replies
• 489 views
• 2 likes
• 2 in conversation