Hello all,
I want to screen thought a set of 6 dichotomous variables (1/0), that each accounts for one disease (D1-D6)
From those I want to create another categorical variable (Dany) that will separate observations with '0-1 disease' and '=>2 more diseases'.
I imagine this can be done with an array but I am quiet unsure how.
Any tips are appreciated!
scvp
Even easier than using arrays:
two_plus = sum(of d1-d6) > 1;
The new variable TWO_PLUS will be 1 (for two or more diseases) and 0 (for fewer than two diseases).
And an excellent example of why coding dichotomous as 1/0 instead of Y/N, T/F or similar character coding schemes.
Another approach might be to just do the sum and use a format to create groupings on a single value such
proc format;
value disease2groups
0,1 = '0 or 1'
2-high ='2 or more'
;
value disease3groups
0,1 = '0 or 1'
2,3 = '2 or 3'
4 - high = '4 or more'
;
run;
Then use the format at the time of use for which grouping is desired on the sum variable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.