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 (June 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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

Hi Sharad, first of all: there are many different methods of merging, especially with SQL. 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 PROQ SQL.

proc sql; create table merged as select * from dataset1 a, dataset2 b where a.key=b.key ; quit;

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. Gerhard

On Mon, 18 Jun 2007 20:35:45 -0700, sharad <sharadoffline@GMAIL.COM> wrote:

>Hi All, > >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. >Sharad


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