Date: Mon, 19 May 2008 09:46:27 -0700
Reply-To: "dc353@hotmail.com" <dc353@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "dc353@hotmail.com" <dc353@HOTMAIL.COM>
Organization: http://groups.google.com
Subject: merge question
Content-Type: text/plain; charset=ISO-8859-1
I have three datasets. The first has shares and ID, the second has
date, id, wgt and the third has date, id and exp(s).
The following code almost works but is there a way to do this with one
merge statement? (If the first file has an ID that is not in
test_merge I get one record added - I'd like to get a recorded added
for each date)
proc sort data=barra.test_por;
by ticker;
proc sort data=barra.sap500_hist;
by yearmonth ticker;
proc sort data=barra.exp_9001_0805;
by yearmonth ticker;
run;
DATA barra.test_merge;
merge barra.sap500_hist (in=b) barra.exp_9001_0805 (in=c) ;
by yearmonth ticker;
where yearmonth => 200703 and yearmonth =< 200704; if b then output;
run;
proc sort data=barra.test_merge;
by ticker;
data barra.test_merge2;
merge barra.test_por barra.test_merge;
by ticker;
run;