Using the UNION Set Operator

A Brief Overview

The set operator UNION does both of the following:
  • selects unique rows from both tables
  • overlays columns
Figure 4.5 UNION Set Operator Relationship
UNION Set Operator Relationship

Example: Using the UNION Operator Alone

To display all rows from the tables Col1 and Col2 that are unique in the combined set of rows from both tables, use a PROC SQL set operation that includes the UNION operator.
proc sql;
   select *
      from certadv.col1 union
   select *
      from certadv.col2;
quit;
Output 4.16 PROC SQL Query Result Illustration
With the UNION operator, PROC SQL first concatenates and sorts the rows from the two ...

Get SAS Certified Professional Prep Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.