6# sas_user 谢谢你,我将你的程序应用了还不错,下面是我要写的程序:options mprint; %macro data_avg;
%let a=%str(B20,B21,J11,J12,J13,J13A,J14,J15,J16,J17,J17A,J18,J36);
%do i=1 %to 13;
%let x=%scan(&a,&i);
%do q=5 %to 17;
%do p=1 %to 12;
proc sql;
select avg(_COL&q) into:mean
from fenxi.b
where _COL0="&x" and mon=&p;
quit;
data a;
set a;
if _COL0="&x" and mon=&p and _COL&q=. then _COL&q=&mean;
run;
%end;
%end;
%end;
%mend;
%data_avg