Any difference between union all corresponding and outer union corresponding?

It turns out there is, actually, a difference: how columns which only exist in one dataset are handled. Outer Union Corresponding will display columns that appear only in one dataset, not overlaid by position. Union All Corresponding will not display any columns that appear in only one dataset.


My understanding is that OUTER UNION and UNION ALL are effectively if not actually identical. CORR is needed for either one to guarantee the columns line up; with OUTER UNION the columns will not stack even if they are identical, while with UNION ALL the columns always stack even if they are not identical (must be same data type or it will error), and pay no attention at all to column name. In both cases adding CORR causes them to stack.

Here are some examples:

Not stacking:

proc sql;
select height, weight from sashelp.class
union all 
select weight,height from sashelp.class;
select height, weight from sashelp.class
outer union
select height, weight from sashelp.class;
quit;

Stacking:

proc sql;
select height, weight from sashelp.class
union all corr
select weight,height from sashelp.class;
select height, weight from sashelp.class
outer union corr
select height, weight from sashelp.class;
quit;

This SAS doc page does a good job of showing the differences.

Tags:

Sql

Sas