Hi. This is just a slight variation of an SQL solution that was posted on the SAS Community (not everyone has access to SAS/ETS and PROC EXPAND) ...

* add an observation number to the already sorted data set;
data series;
set series;
x = _n_;
run;

proc sql;
create table moving as
select *,(select mean(y) from series where x between a.x-4 and a.x) as moving_avg
from series as a;
quit;

The value of MOVING_AVG first four observations use 1, 2, 3, and 4 values of Y to compute the moving average and from then on it's always the current observation plus the previous 4.

It's modified from ...

"rolling standard deviation calculation"
https://communities.sas.com/t5/SAS-Procedures/rolling-standard-deviation-calculation/td-p/160026

posted by SAS Yoda, Ksharp