@eliz1
Or actually: You can use the same variable multiple times in an array definition and though you could just add the variables you need for the first and the last iteration of the do loop to the array. Something like below:
data have(keep=invar_:);
array invar_ {5} 8.;
do obs=1 to 3;
do val=1 to 5;
invar_[val]=obs*val;
if ceil(ranuni(1)*4)=1 then call missing(invar_[val]);
end;
output;
end;
run;
data want;
set have;
array invars {0:6} invar_3 invar_: invar_3;
array outvars {*} 8. outvar_1 - outvar_5;
do i=1 to dim(invars)-2;
outvars[i]=mean(invars[i-1],invars[i+1]);
end;
run;
... View more