Found a convenient solution, still for the sake of diversity...
My own approach (which is a modified version from my personal macro functions library).
%macro join(ALIAS1,ALIAS2,VARLIST,VARNUM); %let varname=%scan(&VARLIST,&VARNUM,%str( )); %if %str(&varname) ne %str() %then &ALIAS1..&varname = &ALIAS2..&varname and %join(&ALIAS1,&ALIAS2,&VARLIST,%eval(&VARNUM+1));
%else 1 %mend join;
Used like this:
options mprint; proc sql noprint; create table mydata as select ... on %join(a,b,cat_order grp_order year,1); quit;
Will recursively build the join clause appending "and 1" at the end (doesn't affect the AND logic)
MPRINT(JOIN): a.cat_order = b.cat_order and MPRINT(JOIN): a.grp_order = b.grp_order and MPRINT(JOIN): a.year = b.year and MPRINT(JOIN): 1
ALIAS1=left alias,ALIAS2=right alias,VARLIST=columns list,VARNUM=first column to start
Daniel Santos @ www.cgd.pt
... View more