data test;
input year price;
p1=lag(price);
p2=lag2(price);
if _n_ ge 3 then mean=mean(price,p1,p2);
drop p1 p2;
datalines;
1980 20
1981 22
1982 30
1983 28
1984 35
1984 36
1985 37
1986 40
1987 43
1988 50
;
run;
proc print ;
format mean 8.2;
run;