Add the following SAS command to help you self-diagnose the problem -- you will see how SAS is resolving your macro variable. More specifically, you declared the macro variable at a point where it either has not value or the value is static, and then you intend to iterate with the %DO / %END. Review the SAS log after adding:
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC;
You will see the processing in detail -- hopefully that will help.
Your code does no assign a variable value to SCHOOL in all cases, so you are getting an unresolved macro variable error. So, your %LET logic needs to be complete for all possible CPT values -- possibly just adding a %ELSE %LET assignment statement -- I don't know your application's needs though, so you must decide, or maybe a null value?.
Being a new SAS user, maybe some basics review is in order. It's unclear how you can expect to support your own code, if you cannot understand how it is executing. That was one reason for suggesting you expand the amount of SAS-generated diagnostics information to your log.
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.
input school $;
call symput(compress("school" || put(_n_, best.)), school);