Date: Mon, 9 Dec 2002 04:34:21 -0800
Reply-To: Paul von Hippel -- Ohio State <pvh@CCRMA.STANFORD.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul von Hippel -- Ohio State <pvh@CCRMA.STANFORD.EDU>
Subject: Re: merge without overwrite
Content-Type: TEXT/PLAIN; charset=US-ASCII
Thanks. Renaming the variables certainly works.
But unfortunately in the real application there are ~100 variables.
On Sun, 8 Dec 2002, Steven Goins wrote:
>Use the RENAME dataset option in your last DATA step.
>
>data ab;
> merge a(Rename = (y = YA)) b(ReName=(y=YB));
> by x;
>run;
>
>
> hth,
>Steve
>
>"Paul von Hippel -- Ohio State" <pvh@ccrma.Stanford.EDU> wrote in message
>news:Pine.LNX.4.44.0212081851280.3095-100000@ccrma-gate.stanford.edu...
>> Suppose I'm match-merging two data sets A and B, whose variables
>> have the same names. SAS' default behavior is for the B variables
>> to overwrite the A variables, but actually I want to keep both
>> with appropriately modified names. That is, I would like the output
>> of the code below to be
>> X Ya Yb
>> 1 2 3
>> instead of
>> X Y
>> 1 3
>> Short of changing the variable names in A or B, is there a simple
>> way to make this happen?
>>
>> data a;
>> input x y;
>> datalines;
>> 1 2
>> ;
>> run;
>>
>> data b;
>> input x y;
>> datalines;
>> 1 3
>> ;
>> run;
>>
>> data ab;
>> merge a b; by x;
>> run;
>>
>> proc print data=ab; run;
>>
>
>
>
|