When doing outer join (match merge) in SAS by a common variable, and this variable has a different name in each dataset, you must rename the common variable. This can done within one (single) data step:

DATA TTTEMP;

Merge librarynam.dataset1 ( Rename= (common_varOLD1= common_varNEW ) ) librarynam.dataset2 (Rename= (common_varOLD2= common_varNEW) ) ;

BY common_varNEW;

RUN;

Advertisement