BookmarkSubscribeRSS Feed
scvp
Calcite | Level 5

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

2 REPLIES 2
Astounding
PROC Star

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).

ballardw
Super User

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.

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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