Date: Tue, 8 May 2012 10:54:08 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Deleting Variables
In-Reply-To: <201205081551.q48Eb0CS031043@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Guess you're on you own!
On Tue, May 8, 2012 at 10:51 AM, Randy <randistan69@hotmail.com> wrote:
> Dear All:
> None of these codes work. :-(
> Randy
>
> On Tue, 8 May 2012 15:06:52 +0000, Zdeb, Michael S <mzdeb@ALBANY.EDU>
> wrote:
>
> >hi ... another idea (it's really "deleting observations" not "deleting
> variables" ... yes/no?)
> >
> >data x;
> >input id vara varb;
> >datalines;
> >1 1 .
> >1 2 1
> >1 3 0
> >2 1 .
> >2 2 0
> >2 3 0
> >;
> >
> >data want (drop=info);
> >length info $100;
> >do until (last.id);
> > set x (in=one) x;
> > by id;
> > if one then info = catx('*',info,catt(vara,varb));
> > if ^one and ^(find(info,'20') and find(info,'30')) then output;
> >end;
> >run;
> >
> >Mike Zdeb
> >U@Albany School of Public Health
> >One University Place (Room 119)
> >Rensselaer, New York 12144-3456
> >P/518-402-6479 F/630-604-1475
> >
> >________________________________________
> >From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Randy
> [randistan69@HOTMAIL.COM]
> >Sent: Tuesday, May 08, 2012 10:13 AM
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: Deleting Variables
> >
> >My dataset is as follows:
> >
> >ID varA VarB
> >1 1 .
> >1 2 1
> >1 3 0
> >2 1 .
> >2 2 0
> >2 3 0
> >
> >I want to delete each ID where VarA = 2 and VarB =0 and VarA = 3 and VarB
> >= 0. Note that for all VarA = 1 VarB = . .
> >
> >so my data set should look like this :
> >
> >ID varA VarB
> >1 1 .
> >1 2 1
> >1 3 0
> >
> >I wrote the following:
> >
> >data want ; set have ;
> >if (VarA = 1 and VarB = .) and
> >(VarA = 2 and VarB = 0) and
> >(VarA = 3 and VarB = 0) then delete ;
> >run;
> >
> >Somehow, I am not getting the logic correct. Please help.
> > Randy
>
|