BookmarkSubscribeRSS Feed
ellieokay
Calcite | Level 5

I am using SAS 9. Let's say my data appears as the following: 

 

Pt         Disease1        Disease2      Disease3     Disease4      

1               .                    1                       .              1

2               .                    .                       1              .                   

3               1                   .                       .               .

4               .                    .                       .               1

5               1                   .                       1              .

6               .                    1                      .               .

 

Most of my patients only have one disease, but I would like to capture patients with multiple diseases, so desired output would be 

Pt         Disease1          Disease2     Disease3     Disease4

1                .                     1                     .               1

5                1                     .                     1               .

 

I've tried something like "if (disease1 and disease2 and disease3 and disease4) ge 2 then diseaseMult=1" but that is not working. Is there a way to say something like "if at least 2 of (disease1 and disease2 and disease3 and disease4)=1 then diseaseMult=1"? 

 

Thanks! 

 

1 REPLY 1
novinosrin
Tourmaline | Level 20

data have;
input Pt         Disease1        Disease2      Disease3     Disease4      ;
cards;
1               .                    1                       .              1
2               .                    .                       1              . 
3               1                   .                       .               .
4               .                    .                       .               1
5               1                   .                       1              .
6               .                    1                      .               .
;

data want;
set have;
if sum(of disease:)>1;
run;