Date: Sat, 13 Dec 1997 16:18:28 -0500
Reply-To: Anthony Ayiomamitis <ayiomamitis@IBM.NET>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Anthony Ayiomamitis <ayiomamitis@IBM.NET>
Organization: IBM.NET
Subject: Re: A "MERGE" problem
Content-Type: text/plain; charset=us-ascii
Antonio Wong wrote:
>
> Hi all,
>
> I have a MERGE problem here and hope someone can provide help.
>
> Suppose I have the 2 dataset, A and B.
>
> dataset A
> AVAR1 AVAR2 AVAR3
> 10 20 30
> 20 30 40
> 30 40 50
> 40 50 60
>
> dataset B
> BVAR1 BVAR2
> 1 2
> 2 3
>
> I want to merge two together so there are 8 observations 5 variables as
> follow:
>
> AVAR1 AVAR2 AVAR3 BVAR1 BVAR2
> 10 20 30 1 2
> 10 20 30 2 3
> 20 30 40 1 2
> ...
>
> 40 50 60 2 3
>
> I try the following code by it fails:
>
> DATA M;
> MERGE A B;
>
> Can anyone can give me some suggestions?
>
> Thanks and best regards,
>
Antonio,
This is a nice match for PROC SQL ...
data avars;
input avar1 avar2 avar3;
cards;
10 20 30
20 30 40
30 40 50
40 50 60
run;
data bvars;
input bvar1 bvar2;
cards;
1 2
2 3
run;
proc sql;
create table master as
select a.*,
b.*
from work.avars a,
work.bvars b;
quit;
proc print;
run;
Anthony.
|