LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2012, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 8 May 2012 12:02:11 -0400
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: Deleting Variables
Comments: To: SUBSCRIBE SAS-L Anonymous <randistan69@HOTMAIL.COM>

If I understood your request correctly, you want to keep all records for an ID, as long as (VarA = 2 and VarB =0) and (VarA = 3 and VarB >= 0) is not true. The first condition and second condition do not have to be true for the same record, as long as they are in the same ID:

proc sql; select * from have group by id having not (max(VarA = 2 and VarB =0) and max(VarA = 3 and VarB >= 0)) ;

ID varA VarB ----------------------- 1 1 . 1 3 0 1 2 1

On Tue, 8 May 2012 11:51:06 -0400, 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


Back to: Top of message | Previous page | Main SAS-L page