Hello @DDawaba and welcome to the SAS Support Communities!
You can also use variable lists such as _numeric_ directly in the MEAN function, so you don't need arrays.
Example:
data want;
set sashelp.baseball;
totavg=mean(of _numeric_);
avg2=mean(of CrBB-numeric-logSalary);
run;
I read the variable names CrBB and logSalary (the first and last item in the list of the last six numeric variables in SASHELP.BASEBALL) off PROC CONTENTS output:
proc contents data=sashelp.baseball varnum;
run;
To avoid this manual step and hardcoding of variable names you can tell PROC SQL to create an equivalent variable list for you:
proc sql noprint nowarn outobs=6;
select name into :last6numvars separated by ' '
from dictionary.columns
where libname='SASHELP' & memname='BASEBALL' & type='num'
order by varnum desc;
quit;
Then replace CrBB-numeric-logSalary by a reference to macro variable last6numvars in the assignment statement for avg2 in the DATA step above:
avg2=mean(of &last6numvars);
... View more