How to find the mean value of columns in SAS
sas
Solution
Assuming all your required variables begin with d, then you can use the colon wildcard operator to select them all. I've used PROC SUMMARY here, this is identical to PROC MEANS with the NOPRINT option. Obviously this is a very minor alteration of the answer from @pteranodon
proc summary data=have nway;
var d: ;
output out=want (drop=_:) mean=;
run;
Problem
I have a SAS data set, let's say: ``` No d1 d2 d3 ... dn 1 2 3 4 ... n1 2 3 4 5 ... n2 3 4 5 6 ... n3 ``` I now need to find the averages of all columns in SAS. Is there a way to do it? The number of columns is not specific. If I need the averages of `d1`-`dn` columns, then the output I expect is: ``` 3 4 5 .. (n1+n2+n3)/3 ``` Is there a way to do this Either in the data step or using proc sql or proc iml?