Date: Tue, 30 May 2006 08:18:53 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: Problem merging files
Nuno,
I would think that something like the following should work:
proc sort data=ret;
by bench_ref date;
run;
proc sort data=bench;
by bench_ref date;
run;
data ret;
merge ret bench (in=b);
by bench_ref date;
if b;
run;
HTH,
Art
-------
On Tue, 30 May 2006 09:59:18 +0100, Nuno Soares <ns.mlists@GMAIL.COM>
wrote:
>Hi everyone,
>
>I'm having an issue with the merging of some data. I have two files:
>- ret: file with the returns for a series of companies;
>- bench: file with the benchmark returns.
>
>The ret file has the following structure:
>Company date ret bench_ref
>A jan90 .01 1
>A feb90 .02 1
>(...)
>A oct90 .01 1
>B jan90 .02 1
>(...)
>B dec90 .03 1
>
>As you can see company A has doesn't have returns for the last two months
of
>1990.
>
>The bench file has the following structure:
>
>Bench_ref date b_ret
>1 jan90 .005
>1 feb90 .001
>(...)
>1 oct90 .02
>1 nov90 .03
>1 dec90 .01
>2 jan90 .01
>2 feb .005
>(...)
>2 dec90 .01
>
>The problem is that I need to merger both files in such a way that the ret
>file includes all the months of the year, ie, that company A also has a
ret
>for Nov90 and Dec90:
>
>Company date ret bench_ref b_ret
>A jan90 .01 1 .005
>A feb90 .02 1 .001
>(...)
>A oct90 .01 1 .02
>A nov90 . 1 .03
>A dec90 . 1 .01
>B jan90 .02 1 .005
>(...)
>B dec90 .03 1 .001
|