This is a good example of the usefulness of PROC SQL ; You can merge to the same dataset multiple times, each time, merging by a different variable. Notice that I added an alias to each variation on the B table to distinguish the AMT that I want, and I used a LEFT OUTER JOIN to keep the data from A in case it does not match a value in B. proc sql ; create table AB as select A.QUE1, B1.AMT as AMT1, A.QUE2, B2.AMT as AMT2, A.QUE3, B3.AMT as AMT3, A.QUE4, B4.AMT as AMT4, A.UNIQUE from A left outer join B as B1 on A.QUE1 = B1.QUE_ALL left outer join B as B2 on A.QUE2 = B2.QUE_ALL left outer join B as B3 on A.QUE3 = B3.QUE_ALL left outer join B as B4 on A.QUE4 = B4.QUE_ALL order by A.UNIQUE ; quit ; proc print data = AB ; run ;
... View more