You have only one variable listed in the VAR statement of PROC CORR each time the macro runs. SAS can't read your mind and figure out you really want four variables in the PROC CORR statement.
You can do a lot of debugging yourself, and identify this problem, if you place the command options mprint; at the beginning of your program, run it again, and look at the LOG and see what code has been generated by your macro.
You need all four of your variables in the VAR statement to get a correlation matrix. To get this, you will need to merge four data sets together. Then, here's an example:
options mprint;
%macro com(c);
%do i=1 %to 12;
proc corr data=on_cl_onl_gr_&i.;
var
%do j=1 %to %sysfunc(countw(&c));
%scan(&c,&j,%str( ))_scale_score
%end;
;
ods output PearsonCorr=corr_gr_&i.;
run;
data corr_gr_&i.;
set corr_gr_&i.;
grade=&i.;
run;
%end;
%mend;
%com(listening reading speaking writing)
You would also benefit from a better data structure. It seems that you have data sets named with one of (listening reading speaking writing) in the data set name, and I would recommend you avoid this. If you combine all four of your variables into one data set, then all 12 (indexed by &i) into a single large data set, you would not need a macro at all.
Lastly, it would seem that you haven't followed the first rule of macro writing, that is to create code for one case (like when &i=1) that works WITHOUT macros and without macro variables. Once you have that, you have working template from which you can create a macro. If you can't start with working code without macros and without macro variables, then your macro will never work.
--
Paige Miller