From: sas analysis on
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.
From: xlr82sas on
On Mar 17, 10:17 am, sas analysis <sasanaly...(a)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.

Here is one solution, you will probably get many better solutions.

data tre;
input
ID & $ base1 & $ base2 & $;
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 sql;
create
table yes as
select
*
from
tre
group
by id
having
max(base1='N' or base2='N')=0
;quit;