Do you have SAS/ETS? If so, look into Proc EXPAND.
Otherwise here's an example of calculating min/max with a temporary array that could be expanded for your situation.
/*
How to calculate a moving min/max with a window of 4.
Resets by group ID
https://communities.sas.com/message/244232
Courtesy of PGStats
*/
data want;
array p{0:3} _temporary_;
set have; by object;
if first.object then call missing(of p{*});
p{mod(_n_,4)} = price;
lowest = min(of p{*});
highest = max(of p{*});
run;
... View more