Hi SAS expert, I'm trying to calculate idiosyncratic skewness of residual in a rolling regression using past 6 months data. The regression is regress individaul stock return on market return:
reg ret mktret
For each month t, I run the regression using t-1 to t-6 data, and get the residual and calculate skewness of residual
Please show a sample of the data, in the form of a working data step - so that proposed code can be tested.
In particular, how are you constructing data to be submitted for rolling window regressions?
1. Are you using forward, backward, or centered windows?
2. For the regression, do you want a least-squares regression for k=6 time points, or do you want a moving average?
3. Do you have access to SAS IML software?
You can review common moving-window statistics by reading the article, "Compute a moving average in SAS."
Since the skewness of residuals for a moving regression is not built into any SAS procedure, I suggest you program it yourself in the SAS IML Language. The basic ideas are shown in the article, "Rolling Statistics in SAS/IML". A second article on rolling medians shows how to extract the data from a rolling window.
I would tackle this problem in two steps:
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.