Creating rolling windows of data

Reply
Occasional Contributor
Posts: 7

Creating rolling windows of data

Hi,

We want to create rolling windows of time series data. We are able to do this for one ID, however we are unsure how to group for multiple IDs

The following code works for one ID and is taken from http://www.lexjansen.com/nesug/nesug12/fi/fi08.pdf:

DATA rwin / view=rwin;

ws = 52;

nwin = nrecs - ws +1;

do w=1 to nwin;

do p=w to w + ws -1;

set have point=p nobs=nrecs;

output;

end;

end;

stop;

run;

proc reg data=rwin noprint outest=stats tableout;

by w;

model y=x1 x2;

quit;

Super User
Posts: 9,662

Re: Creating rolling windows of data

Post your test data and the output you need .

Ask a Question
Discussion stats
  • 1 reply
  • 146 views
  • 0 likes
  • 2 in conversation