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 (March 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 9 Mar 2001 08:20:33 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: subsetting with WHERE ?

Here's another way.

First, create a suitable BY variable. Save a pass through the data by making it a view.

data grouped / view=grouped; set [name of existing SAS data set]; if name='A' then groupnum ++1; run;

Now interleave the data set with itself so the each group of records can be previewed before it is processed.

data subset; drop groupnum want; set grouped(in=preview) grouped(in=process); by groupnum; if first.groupnum then want = 1; retain want; if preview and name in ('C','D') and x>=0.5 then want = 0; if process and want then output; run;

On Thu, 8 Mar 2001 21:16:34 +0100, Torben Haslund <Torben.Haslund@VBIOL.SLU.SE> wrote:

>Dear SAS-Lers > >I have a SAS data set with many blocks, each of 4 rows, as follows: > >NAME x y >A 0.8 0.9 >B 0.7 0.9 >C 0.3 0.9 >D 0.4 0.9 >A 0.2 0.8 >B 0.3 0.8 >C 0.6 0.8 >D 0.4 0.8 >A 0.2 0.7 >B 0.5 0.7 >C 0.6 0.7 >D 0.7 0.7 >. >. >. > >Y is equal for all 4 rows in a group. >How can I subset the data, so I keep the rows within a group together, and >want all groups where C and D are < 0.5 ? > >The example above should give: > >NAME x y >A 0.8 0.9 >B 0.7 0.9 >C 0.3 0.9 >D 0.4 0.9 > >TIA > >torben > > > > > > > > >::::::::::::::::::::::::::::::::: >Torben Haslund >Department of Plant Biology >Swedish University of Agricultural Sciences >P.O. Box 7080 >S - 750 07 UPPSALA, Sweden > >E-mail address: Torben.Haslund@vbiol.slu.se >Home and postal address: Ostre Paradisvej 7B, > DK-2840 HOLTE, Denmark >Phone home: +45 4541 1198


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