@Reeza 's suggestion made me recall a technique I have sometimes used for rolling windows - namely to output a copy of each data record once for each window in which it belongs (and assigning a consistent ending date for each window).
Then run a proc summary or proc means using the window end date as a class var:
data have;
input date :monyy7. x;
format date date9.;
datalines;
AUG2015 26
AUG2015 27
SEP2015 16
SEP2015 20
SEP2015 7
OCT2015 22
NOV2015 28
NOV2015 28
NOV2015 35
NOV2015 15
DEC2015 28
DEC2015 8
DEC2015 14
;
data vneed / view=vneed;
set have nobs=nrecs;
if _n_=1 then do;
/*Generate the window end date needed for the 1st 3-month window*/
set have (keep=date rename=(date=first_date));
first_date=intnx('month',first_date,2,'end');
/*Generate the window end date needed for the last 3-month window */
set have (keep=date rename=(date=last_date)) point=nrecs;
last_date=intnx('month',last_date,0,'end');
end;
/* Write a record for each window it belongs to */
do m=0 to 2;
window_enddate=intnx('month',date,m,'end');
if first_date<=window_enddate<=last_date then output;
end;
format window_enddate date9.;
run;
proc means data=vneed median ;
var x;
class window_enddate;
run;
... View more