So here's something to think about when or if you try writing another macro.
Macros are simply used to substitute text into your SAS program. Where you actually see macro variables or macro code in your program, the text values created by the macro code are substituted into SAS when you execute your program.
And when this substitution happens, it must result in valid legal SAS code with no errors, and obviously, the code must do what you want. That's so important, I'm going to say it again.
when this substitution happens, it must result in valid legal SAS code with no errors
So if your original code has
STUDY_&d.;
then when &d is 1, the text placed into the code when SAS executes is
STUDY_1;
and the semi-colon is wrong if you are expecting to add additional data set names to the SET statement. Why? Because the result would be
SET STUDY_1; STUDY_2; STUDY_3;
and this will produce errors.
... View more