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 (April 2002, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 29 Apr 2002 14:45:33 -0400
Reply-To:     "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject:      Re: Unusual subsetting
Comments: To: "Friberg, Ingrid (DHS-DCDC)" <IFriberg@DHS.CA.GOV>
Content-Type: text/plain; charset="windows-1252"

Ingrid,

Harry has provided a nice SQL solution. Here is another approach.

(1) Output A proc freq data set on the input data with ID as the BY group. (2) Merge with the original subsetting with a where clause (see code below).

data q ; input ID Other ; cards ; 1 1 1 1 1 1 2 1 2 0 2 1 3 0 3 0 3 0 ;

proc freq noprint data = q ; tables other / out = f ; by id ; run ;

data allsame differnt ; merge q ( in = a ) f ( in = b where = ( percent = 100 ) ) ; by id ; drop count percent ; if a and b then output allsame ; else if a and not b then output differnt ; run ;

Kind Regards,

Venky #****************************************# # E-mail: swovcc@hotmail.com # # Phone: (734) 622-1963 # #****************************************#

-----Original Message----- From: Friberg, Ingrid (DHS-DCDC) [mailto:IFriberg@DHS.CA.GOV] Sent: Monday, April 29, 2002 2:24 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Unusual subsetting

Hi,

I have no idea how to do this!!

I have a dataset with a bunch of patients matched by id number. I have another variable which may or may not be the same for all of my matched patients. How do I select the subset of matches where they all have the same other variable

i.e.

ID Other 1 1 1 1 1 1 2 1 2 0 2 1 3 0 3 0 3 0 I want all of ID number 1 and 3 to go to one database and all of id 2 to go to another. Is this the sort of thing where I would need to use a lag function? or some sort of loop function? I could do it by hand, but that would take too long, evenf or my relatively small dataset!!

Thanks!!

Ingrid


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