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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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