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
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;
> 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;
> 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 aina | e-mail: firstname.lastname@example.org | fax:(604) 291-5944 |