I used the code to create rolling window for 12 months (t-12) to calculate R2, residual... for month t .
01JAN2000 to 31DEC2000 --> JAN2001
01FEB2000 to 31JAN2001 ---> FEB 2001
01MAR2000 to 31FEB2001 ---> MAR 2001
I can run with monthly data, but for DAILYdata I cannot use this code:
create table Form100
as select distinct a.permno, a.date as end, b.ret, b.date
from crsp3 (keep=permno date) as a, crsp3 as b
where a.permno=b.permno and 1<=intck("month", b.date, a.date)<&J and 0<=intck("year",b.date,a.date)<=1
group by a.permno, a.date;
Could you please me with this? THank you very much.
b. date from 01JAN2000 to 31DEC2000 --> it will be used for hold year to calculate in JAN2001 (a.date, can be 01Jan2001 or 31 jan2001, it is not important)
b. date from 01FEB2000 to 31JAN2001 ---> will be used for next month in FEB 2001 (a.date shift one month)
b. date from 01MAR2000 to 31FEB2001 ---> MAR 2001
How large is your data? Do you need to add in all the data for the 12 months or are you trying to calculate some sort of statistics across the interval. Otherwise you're going to be multiplying the size of your data significantly since each record will belong to multiple intervals.
Also, do you have SAS/ETS? Have you looked at PROC TIMESERIES or EXPAND?
My data has 27.612.898 observations. I want to create to run proc preg for R2 and residual (CAPM model) and skewness (has formula). If data is too large, I just use it for calculate one by one, if I can find solution.
Thank you so much for suggestion, I am just gg search and reading how to use but I have no idea until now.
it is good for SQL to get ROLLING window.
code not tested.
proc sql; create table Form100 as select a.permno, a.date as end, (select sum(residual) from crsp3 where permno=a.permno and date between a.date and intnx('year',a.date,1,'s')-1 ) as sum_residual from crsp3 (keep=permno date) as a group by a.permno, a.date; quit;
Thank you, I am going to check now. But I want create rolling window to calculate R2, residual (must use proc preg for regression market model) and skewness.
So can i combine proc preg and proc sql? and how about skewness?
Thank you so much,
These two papers I presented at NESUG discuss (1) how to make rolling windows of the original data, and (2) how to make rolling SSCP matrices ready for use in PROC REG. Did you know that there is a sas data set TYPE=SSCP that proc reg accepts? Take a look at these:
I'd probably avoid making your own implementation of Cramer's rule (I wrote that mostly as an exercise), but even so, the second paper probably provides a better guide to making the rolling TYPE=SSCP data set for to PROC REG. Now remember, submitting an SSCP matrix means you can directly produce TOTAL residuals for each window, but not day-by-day residuals. To do that, you'd have to take the intercept and coefficients estimates for each window and run them against your data.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.