The issue is obvious in this simple example, but it's pretty easy to miss with something more complicated:
data T1;
input id A B C;
cards;
101 3 7 8
102 5 2 1
;
run;
data T2;
input id A B C;
cards;
103 8 2 5
104 6 1 2
;
run;
proc sql;
select * from T1;
select * from T2;
select id, A, B, C from T1
union all
select id, B, A, C from T2
order by id;
quit;
The result:
'
The log:
