if the line ods tagsets.EXCELXP file="D:\S\&school.xls" ; is not inside the macro then &school has not been assigned. Secondly the macro var school resolving within a string needs a terminator. SAS assumes this is what the . is for so you will get no . between the name and xls. You need to write this as
ods tagsets.EXCELXP file="D:\S\&school..xls" ; with .. after the &school.
As Scott pointed out you seem to be having trouble with very basic concepts of macros, and need to get a handle on these. If it will help you, I might write this code something like the following.
data _null_;
input school $;
call symput(compress("school" || put(_n_, best.)), school);
cards;
0372604S
0370049P
0370002N
;;;
run;
%macro test ;
%do cpt = 1 %to 3 ;
%put &&school&cpt ;
ods tagsets.EXCELXP file="D:\S\&&school&cpt..xls" ;
proc freq data= a.table (where=(school="&&school&cpt"));
table school*var1*var2*var3/ missprint nocol nopercent nofreq norow noprint out= sasuser.tbx1&&school&cpt ;
format school $school. ;
run;
ods tagsets.Excelxp close;
%end ;
%mend ;
%test ;
... View more