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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 585 views
  • 1 like
  • 2 in conversation