DATA Step, Macro, Functions and more

Screening Several Variables to Create Conditional Varible

Reply
Occasional Learner
Posts: 1

Screening Several Variables to Create Conditional Varible

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

Super User
Posts: 6,933

Re: Screening Several Variables to Create Conditional Varible

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

Super User
Posts: 13,941

Re: Screening Several Variables to Create Conditional Varible

Posted in reply to Astounding

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.

 

Ask a Question
Discussion stats
  • 2 replies
  • 80 views
  • 2 likes
  • 3 in conversation