sasanalysisproc-sql

Append 2 columns from a single table into one column in SAS


Can someone please help me with this sort of append. Here is the input data - enter image description here

Here is the output I'm expecting - enter image description here

Attached is the code for input data -

data have;
input ID Emp1 $ Emp2 $;
cards;
1 Ani Mia
1 Pat Vul
1 Kiu Max
run;

Thanks!!


Solution

  • Try this:

    PROC SQL;
    CREATE TABLE WORK.Append_Table AS 
    SELECT Emp1 AS All_Emp FROM WORK.HAVE  /* Table 1, Column 1 */
     OUTER UNION CORR 
    SELECT Emp2 AS All_Emp FROM WORK.HAVE  /* Table 1, Column 2 */
    ;
    Quit;