Using a data row in a rolling window computation means the data row needs to be replicated for association to each window it will be part of (i.e. partitions).
A data row will thus need to be repeated with an appropriate window identifier that iterates from window (date) to window+N (of date). A month based window id from a date (your variable t) can be computed with INTCK('month',...)
Example:
Using @mkeintz data generator and summary.
* generate some data; %let nv=5000;
*%let nv=0010;
data have(drop=i);
format t yymmddn8.;
array var{&nv} var0001-var&nv;
do t="1jan2019"d to "31dec2019"d;
do i=1 to &nv;
var(i)=rannor(1);
end;
output;
end;
format var: 8.4;
run;
* compute max month based window id;
proc sql noprint;
select max(intck('month', '01jan1960'd, t))
into :max_seqnum
from have;
%let MONTH_WINDOW = 2;
data stage(index=(seqdate));
length seqnum 8;
set have;
by t; * enforce requirement of data being sorted by t;
* convert date to a month based sequence number (window id);
seqnum = intck('month', '01jan1960'd, t);
* create replicates of row, associating data to N different month window partitions;
do seqnum = seqnum to min(seqnum + &MONTH_WINDOW - 1, &MAX_SEQNUM);
seqdate = intnx('month', '01jan1960'd, seqnum); * first of month for later reporting;
output;
end;
format seqdate monyy7.;
run;
proc summary data=stage;
by seqdate;
var var:;
output out=want skew= / autoname;
run;
Sample output:
_FREQ_ is number of dates contributing to MONTH_WINDOW = 2 rolling month statistic (skew).
... View more