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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.