Hi Everybody, I have a real trouble with a mean calculation.In fact, I want to calculate the rolling mean for this set using a array statement. Here are samples of what I have and what I want. In others words : m0=mean(v0)=v0 ; m1=mean(v0, v1) ; m2=mean(of v0 -v2) & m3=mean(of v0 -v3). I tried this code but got an error : data have;
input v0 v1 v2 v3;
datalines;
2 3 5 4
4 6 2 8
3 4 7 2
;
run;
data want;
input m0 m1 m2 m3;
datalines;
2 2 3 3.25
4 5 4 5
3 3.5 5 4.25
;
run;
data want;
set have;
array temp(0:3) T0 - T3;
array wish(0:3) m0 - m3;
do i = 0 to 3;
if i = 0 then do;
temp(i) = v0;
wish(i) = temp(i)/(i+1);
end;
else temp(i) = temp(i-1) + vi;
wish(i) = temp(i)/(i+1);
end;
run ; NOTE: Variable vi is uninitialized. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 9 at 1062:30 9 at 1063:22 NOTE: There were 3 observations read from the data set WORK.HAVE. NOTE: The data set WORK.WANT has 3 observations and 14 variables. Will appreciate any kind of help!
... View more