I would like to know what is the best way to merge multiple tables. I have a unique identifiers across all the tables. Should I join all the tables in one step after sorting the
You can do multiple merges at single step. However, this is not the safest way. If there is possibility that your data is subject to imperfections, it is best to do this step by step. Imho, it is best do merge a step at the time, but it's your call.
proc sort data=data1; by id; run;
proc sort data=data2; by id; run;
proc sort data=data3; by id; run;
data combo;
merge data1(in=a) data2(in=b) data3(in=c);
by id;
if a and b and c; /*Inner join. Change as needed. */
run;
This is equivalent to:
data partial;
merge data1(in=a) data2(in=b);
by id;
if a and b;
run;
data combo;
merge partial(in=a) data3(in=b);
by id;
if a and b;
run,