I did read it and tried to follow that, and this is what I have come up so far. I appreciate your response, but its not really helpful. Its only when I hit the wall after trying all methods, I come here as I understand everyone's time is precious.
As @error_prone mentioned you need to list all the variables for an array.
You can use variable lists, but your definition isn’t a valid variable list.
See the variable list requirements here.
I believe in this case there is no clean way to define them in arrays since variable names are so different and if I have to write 8 statements to define each difference, what's the point of arrays here. Sorry its beyond me.
Ok, so I finally got it, though im not sure this is the most efficient way as there is so much typing still involved.
data test;
set fish2_;
array all{*} hg n elv sa z da rf fr;
array all_mean{*} hg_mean n_mean elv_mean sa_mean z_mean da_mean rf_mean fr_mean ;
array all_median{*} hg_median n_median elv_median sa_median z_median da_median rf_median fr_median ;
array diff{*} hg_diff n_diff elv_diff sa_diff z_diff da_diff rf_diff fr_diff ;
array diffM{*} hg_diff_me n_diff_me elv_diff_me sa_diff_me z_diff_me da_diff_me rf_diff_me fr_diff_me ;
do i=1 to dim(all);
diff[i]= all_mean{i} - all{i};
diffM[i]= all_median{i} - all{i};
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.