Date: Tue, 19 Jun 2007 03:08:48 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Merging
first of all: there are many different methods of merging, especially with
You seem to mean the MERGE statement in DATA step.
Ok, you are right, you need a primary key in at least one of the datasets,
you want to merge.
If you have repeated values in one of the BY-lists, you get the fitting
data of the other dataset repeated.
A important thing is the (in=in1) option for each dataset. With that you
can have control where the data come from. Remember, that the IN1 is a
temporary variable, not in the output dataset. If you want to see it, you
have to assign it.
With the key you are not limited to 1 variable. All what's in the BY -
list is the key!
by a b c d e;
means, that your key is built of a b c d e.
For sure both datasets have to be sorted by that or have an index.
If you want to have other results, e.g. a cross-product which has all
combinations of all key-variables, not necessary unique, you should use
create table merged as select *
from dataset1 a,
For that the datasets do nopt need to be sorted, and the key-variable(s)
do not need to have the same names. The result however, could be very
different from the DATA - MERGE.
On Mon, 18 Jun 2007 20:35:45 -0700, sharad <sharadoffline@GMAIL.COM> wrote:
>I am trying to match merge two data files but there is no single
>primary key(Unique Variable) on the basis of which i can merge the
>files. I don't know whether i can use 2 or more variables for creating
>a pimary key and then using that primary key for merging. If this can
>be done, then please help me out with the pocess. I will be vey happy
>if someone can explain me the concept of merging, i mean...... how SAS
>compile and execute MERGE Statement.
>Please help me at the earliest.