BookmarkSubscribeRSS Feed
MarinaMag
Fluorite | Level 6

Hello,

 

I am trying to compute firm specific volatility and skewness using monthly stock returns calculated from CRSP monthly stock prices. To be included in the return tests for July of year t, a firm must have Compustat/CRSP data for December of year t 1 and June of year t. It must also have monthly returns for at least 24 of the 36 months preceding July of year t in order to calculate the firms’ volatility and skewness and the firm’s beta. Furthermore, I will proceed with Fama-MacBeth rolling procedure.

I have found one macro for rolling regression (see attachment) and call it as it is below:

%rollingreg (data= Crsp_Comp, out_ds=_outest_ds , id=permno , date=date , model_equation= ex_ret_mon= market_premium ,

start_date=1980 , end_date= 2010, freq=month, s=1, n=36,regprint=yes);

Then I saved the residuals of the regression and compute the standard deviation of the residuals for the volatility measure and skewness respectively but does not seem to work.

Can anyone help me with that?

Thank you in advance.

 

1 REPLY 1
mkeintz
PROC Star

By "returns test for July of year t" do you mean a window ending June 30 of year t, or do you mean a window endow July 31 of year t?

 

Do you only want the "July" windows, or do you want windows for every month?  And if you mean every month, then are you still saying you want December data for year t-1, or do you merely mean 7 months prior to the window ending month?

 

It appears you want 36-month long windows, but will accept up to 12 monthly "holes" in that 36 months, correct?  Which means, at the beginning of your time series, you can have a 24-month window, then a 25-month windows, etc.

 

For a company with complete monthly data for Jan 1980 through Dec 2010, (31 years), there will 31*12 - 23 = 349 regressions for each PERMNO.  So if you have, say, 500 firms, you'll be constructing 174,500 windows.   PROC SQL, which is in the macro you found, is not an efficient way to prepare this data.  Since crsp/compustat data are almost certainly sorted by permno/date (they are at WRDS), you'll be better off either using a data step make window raw data set view, or possibly a view+proc expand to create rolling sums-of-squares for the regression.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 1307 views
  • 0 likes
  • 2 in conversation