@savanahb
The posted code was for guidance. When using SAS macros it's always a judgment call how far you want/need to take things and what needs to be made dynamic - and the further you take it the harder the resulting code will be to "read".
As @Reeza posted, you could also "macrotize" below bit - the list of table name in the merge statement and the IF in1... statement.
data want;
merge
datafile1 (in=in1)
datafile2 (in=in2)
datafile3 (in=in3)
;
by id;
if in1 and in2 and in3;
run;
You could take it even further and implement an input parameters for the macro where you pass in root path and then a list of source files and then have the macro generate SAS code which can deal with a varying number of source files.
How far you need to take this depends on your assignment as well as how much time you can/want to spend on this.
... View more