Date: Wed, 17 Mar 2010 14:50:40 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: deleting subjects
that removes the entire thing from c resulting in d:
data a;
input
ID : $2. base1 : $ 2. base2 :$2.;
cards;
1 Y Y
1 Y Y
1 Y Y
1 Y Y
1 Y Y
2 Y Y
2 Y Y
2 N Y
2 Y Y
3 Y Y
3 Y N
3 Y Y
3 Y Y
;
run;
proc sort data=a out=b;
by id base1 base2;
run;
data c;
set b;
retain ok;
by id;
if first.id then ok=1;
if base1="N" or base2="N" then ok=0;
run;
data d;
set c;
where ok;
drop ok;
run;
Gerhard
On Wed, 17 Mar 2010 10:17:10 -0700, sas analysis <sasanalysis@GMAIL.COM>
wrote:
>Hi,
>
>In a repeated measure dataset, how can I deleted unwanted subjects
>based on a whether they had a value of 'N' in either base1 or base2.
>For example, below I only need to look at ID 1 since both 2 and 3 had
>an 'N' in either base1 or base2. I have also pasted my code below. It
>is deleting the rows that have an N but not removing the entire
>subject from the dataset.
>
>The data looks like this:
>
>ID base1 base2
>1 Y Y
>1 Y Y
>1 Y Y
>1 Y Y
>1 Y Y
>2 Y Y
>2 Y Y
>2 N Y
>2 Y Y
>3 Y Y
>3 Y N
>3 Y Y
>3 Y Y
>
>data x;
>set y;
>by ID;
>if first.ID then d=0;
>if base1='N' or base2= 'N' then d+1;
>if ^d;
>drop d;
>run;
>
>any ideas?
>Thanks.