@abrice520
Amanda,
Everything you're doing is basically correct. You're saying MEAN which is the correct function, and you're using "of" which is the correct way to refer to multiple variables or an array. You're using a variable range, WtOz1 - WtOz2, instead of an array reference. An array reference for an array named WtOzs would be WtOzs[*].
Here's one possible way to code this:
DATA WORK.Mice;
DROP _:;
INFILE DATALINES;
INPUT WtOz1 - WtOz8 @@;
ARRAY WtOzs [*] WtOz1 - WtOz8;
ARRAY DiffOzs [*] DiffOz1 - DiffOz8;
Avg_WtOz = MEAN(of WtOzs[*]);
DO _i = 1 TO DIM(WtOzs);
DiffOzs[_i] = Avg_Wtoz - WtOzs[_i];
END;
DATALINES;
0.57 0.69 0.87 0.86 0.83 0.63 0.68 0.59
;
RUN;
Notice however that I have two arrays. One array is for the values read in, the weights. The other is for the calculation results, the differences. I wouldn't try to do this in one array although you could. If you don't want the weights in your results, then you could just code: DROP WtOz1 - WtOz2.
Since my two arrays are essentially mirror images of one another, a single subscript, _i, can be used to access both. The arrays function in parallel.
Jim