0
votes

I'm trying to append all the tables(same structure) in the work library into one data set. But I need to have a new column name which can indicate the table name. I tried two methods:

  1. macro array and do over:

    PROC APPEND BASE=_dupout DATA=dup_&dataset. FORCE;
    RUN;
    
  2. Proc SQL:

    PROC SQL;
       SELECT MEMNAME, catx('.', libname, MEMNAME) INTO : MEMNAMES SEPARATED BY ' '     
       from dictionary.tables
       where libname='WORK';
    quit;
    
    DATA DUP_OUT;
       SET &MEMNAMES.;
    RUN; 
    

but neither of those I can find a way add a new column (table name). Maybe it is a very simple question? I'm stuck..please help...

1

1 Answers

0
votes

Very close, use the INDSNAME option in your SET statement.

DATA DUP_OUT;
SET &MEMNAMES. INDSNAME=SOURCE;
DSET=SOURCE;
RUN;