BookmarkSubscribeRSS Feed
0 Likes

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:

quickbluefish_0-1747357198973.png'

The log:

quickbluefish_1-1747357300328.png

 

 

1 Comment
whymath
Lapis Lazuli | Level 10

There is a keyword: "corr", to let SAS overlays columns that have the same name in both tables.

Try this:

select id, A, B, C from T1
union all corr
select id, B, A, C from T2
order by id;

 

 

 

OSZAR »