jeudi 29 novembre 2018

SAS Keep if all, else

I have a sas dataset that looks like the following:

ID    Day    Instance1  Instance2
1      1         N         Y
1      2         N         Y
1      3         Y         N
1      4         N         N
2      1         N         Y
2      2         N         N
2      3         N         Y  
2      4         N         N

and I would like to keep instances based on whether or not they are marked yes even once. Else it would be marked no. My desired output would be:

ID   Instance1  Instance2
1         Y         Y
2         N         Y

What I'm trying pseudo code:

DATA test, 
    set.test, 
    by ID;
       if all instance1 = N then N, else yes; 
       if all instance2 = N then N, else yes;
RUN; 

Aucun commentaire:

Enregistrer un commentaire