BookmarkSubscribeRSS Feed
stella_24
Calcite | Level 5

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 Smiley Happy

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

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

Thanks,
Jag
stella_24
Calcite | Level 5

Thank you so much, Jagadish!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1614 views
  • 3 likes
  • 2 in conversation