Dear all,
I have monthly stock observations sorted according to the unique ID number for all US stocks and I need to merge the data file with the corresponding Fama French factors (having daily observations).
How can I achieve that in the new dataset to each monthly observation there is a factor observations matched?
The data looks like this:
Fama French:
date SML HML
19910102 a d
19910103 b f
19910104 c h
...
19910201 x z
Stocks:
permno date price
1001 19910102 1
1001 19910201 2
1002 19910102 3
...
Merged:
permno date price SML HML
1001 19910102 1 a d
1001 19910201 2 x z
1002 19910102 3 a d
Thanks in advance
data data1;
input date SML$ HML$;
cards;
19910102 a d
19910103 b f
19910104 c h
;
data data2;
input permno date price;
cards;
1001 19910102 1
1001 19910201 2
1002 19910102 3
;
proc sort data=data1;
by date;
run;
proc sort data=data2;
by date;
run;
data data3;
merge data1(in=a) data2(in=b);
by date;
if b;
run;
thanks,
jagadish
Thank you so much, Jagadish!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.