Figured this out my self - running the code before moving any observations: proc sort data=avg;
by date;
run;
data avg_1;
set avg;
by Date;
array window{0:379} _temporary_;
array window1{0:379} _temporary_;
if first.hometeam
then do;
do count = 0 to 379;
window{count} = .;
window1{count} = .;
end;
count = 1;
end;
else count + 1;
window{mod(count,380)} = FTHG;
Goals_For_Total = sum(of window{*});
Avg_Goals_For_Total = sum(of window{*}) / min(count,380);
window1{mod(count,380)} = FTAG;
Goals_Against_Total = sum(of window1{*});
Avg_Goals_Against_Total = sum(of window1{*}) / min(count,380);
drop count;
run; /Frederik
... View more