options nocenter ls=80; libname temp 'd:\empirical methods\'; filename tempdir 'd:\empirical methods\'; *Read in data created from Ken French's website for the 25 size and BM portfolios; *Portfolio and id identify the different portfolios; data ret25; set temp.szbmret; year=year(date); month=month(date); proc sort; by date; proc means; run; data size25; set temp.size25; proc sort; by date; proc means; run; data bm25; set temp.bm25; proc sort; by year; proc means; run; *Read in the Fama French Factors from Ken French's website; data fffact; informat date yymmn6.; format date yymmn6.; infile tempdir(F-F_Research_Data_Factors.txt) missover firstobs=5; input date mkt smb hml rf; lmkt=lag(mkt); proc sort; by date; proc print data=fffact (obs=100); proc means; run; data all; merge ret25 size25 fffact; by date; proc sort; by year; run; data all; merge all bm25; by year; if ret=. then delete; *Compute excess returns; exret=ret-rf; if year<1963 then delete; proc sort; by portfolio date; proc means; run; *compute the beta for each portfolio using the contemporaneous and lagged market return; proc reg noprint outest=est1; model exret=mkt lmkt; by portfolio; run; data est1 (keep=portfolio beta); set est1; beta=mkt+lmkt; proc print data=est1; run; data all; merge all est1; by portfolio; lsize=log(size); lbm=log(bm); proc sort; by date; proc means; run; *Compute Fama Macbeth cross-sectional regressions each month and save the coefficients; proc reg data=all noprint outest=estff; model exret=beta; by date; run; *Compute Fama Macbeth t-stats; proc means data=estff n mean t prt; run; *Compute Fama Macbeth cross-sectional regressions each month and save the coefficients; proc reg data=all noprint outest=estff; model exret=beta lsize lbm; by date; run; *Compute Fama Macbeth t-stats; proc means data=estff n mean t prt; run;