I would like to do regression for rolling windows of 5 years for a company. I used a brute force approach like the following: data test;
ws = 5;
nwin = nrecs - ws +1;
do w=1 to nwin;
do p=w to w + ws -1;
set test point=p nobs=nrecs;
output;
end;
end;
stop;
run;
data lib.test; set test; run;
proc reg data=test noprint outest=myests;
by w;
model y=x;
quit;
data lib.myests; set myests; run; However, when I checked my data, I realized that if a cluster/group does not have enough observations of 5, it takes an observation of another company to make it 5. For example: The group w = 1 is fine. However, in the group w = 2, when A & A Foods LTD has only 4 observations, it takes an observation (the first one) of AAON Inc. I would like something like, if a cluster/group has fewer than 5 observations, then it should be removed (not considered), like the case of w = 2 above. How may I do this?
... View more