11-16-2016 11:06 PM
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.
11-16-2016 11:49 PM
Do you mean:
where a.permno=b.permno and /* 1<=intck("month", b.date, a.date)<&J and 0<=intck("year",b.date,a.date)<=1 */
b.date <= intnx('year',a.date,1,same)
what do you have in &j ? - did you assigned it a value ?
11-17-2016 12:35 AM - edited 11-17-2016 12:35 AM
sorry it is not clear enough to me.
give an example by values of a.date= ... b.date= .... valid period from date= to date=
11-17-2016 12:40 AM - edited 11-17-2016 12:42 AM
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
11-17-2016 02:39 AM
Thank you, I am a beginner of Sas so I am trying to find how to create table as you said. But I am running daily stock return for US market, could it use for very large data.
11-17-2016 04:56 AM
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?
11-17-2016 08:25 AM
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.
11-17-2016 05:13 AM
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;
11-17-2016 08:17 AM
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,
11-17-2016 10:03 PM
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.