What am I doing wrong?
Perhaps it is that you are making your program too complicated?
Someone already has given you the answer that you need to add another period to mark the end of the &DSNx macro reference since you need to resolve two different macro variables in front of the fixed text.
&&dsn&i.._MST_TBL
That should have been pretty clear from the warning messages
WARNING: Apparent symbolic reference DSN1_MST_TBL not resolved.
WARNING: Apparent symbolic reference DSN1_CPT_CODE not resolved.
that you got.
But if you just expand your code to make the steps a little clearer it will be easier for both you and SAS to figure out what you are doing.
%do i=1 to &nobs ;
....
%let basename=&&dsn&i ;
%let master=&basename._MST_TBL ;
%let cptfile=&basename._CPT_CODE;
data &master ;
set &cptfile ;
....
%end;
... View more