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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1053 views
  • 3 likes
  • 2 in conversation