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 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 10 Apr 2000 09:03:31 +0200
Reply-To:     Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:      Re: Match merge problem
Comments: To: Victor Aina <aina@SFU.CA>
Content-Type: text/plain

Victor,

Do it all at once: [BY Phone Name Address /* and so on */;] with both SORT and MERGE. You may specify more than one BY variable in a list.

Regards - Jim. -- Y. Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer allows me to be buggy, imperfect; my wife ......

> -----Original Message----- > From: Victor Aina [SMTP:aina@SFU.CA] > Sent: Monday, April 10, 2000 5:55 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Match merge problem > > Hi everyone, > I need to match-merge two datasets. The problem is > this: no single unique match key. There are however > certain variables (common perhaps to the datasets) > e.g. phone, name, address. I proceeded as follows: > First match-merge by phone. Whatever is left (unmatched), > use name as the match-key, and then whatever remains > on matched use address as the key and so on and so forth. > > Thus, I have a code like this: > > proc sort data = dat1; by phone; run; > proc sort data = dat2; by phone; run; > > data merg1 rem1a rem1b; > merge dat1(in=in1) dat2(in=in2) > by phone; > if in1 = 1 and in2 = 1 then output merg1; > if in1 = 0 then output rem1a; > if in2 = 0 then output rem1b; > run; > > proc sort data = rem1a; by name; run; > proc sort data = rem1b; by name; run; > > data merg2 rem2a rem2b; > merge rem1a(in=in1) rem1b(in=in2) > by name; > if in1 = 1 and in2 = 1 then output merg2; > if in1 = 0 then output rem2a; > if in2 = 0 then output rem2b; > run; > > My questions are these: Is there anything wrong with > this approach? What other ways would you approach > the match-merge problem? > > Thanks for you comments and all pointers. > > Victor. > -- > > > +----------------------------------------------------------+ > | victor aina | e-mail: aina@sfu.ca | fax:(604) 291-5944 |


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