From: sas analysis on 17 Mar 2010 13:17 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 17 Mar 2010 14:13 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;
|
Pages: 1 Prev: Help needed with PROC SCORE Next: 5.28: perl How can I read in an entire file all at once? |