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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 516 views
  • 1 like
  • 2 in conversation