0
votes

I'm trying to write a macro. The Marco is about output duplicates. And then append all of them into one dataset. This dataset will have two columns: table name (which I select in one library), primary keys. So, how can I get all the table names in Macro? I thought I can do: dataset='&data.' as a new column into this dataset. But the macro will treat all of them as &data. instead of swap to the table names.

Thank you

1
resolving macrovariables in ' does not work, it uses &data as string, " is what you need here, so use dataset="&data". But i dont understand if this is your question or do you want help building the described datastep in a macro. Its always good to post the code you have, so people can understand the problem better...kl78

1 Answers

0
votes

It was not easy to identify exactly what you are asking for but here are two starting points you can use.

You can use the :into option, to make a macro variable that holds a list of many things separated by a delimiter:

PROC SQL NOPRINT;
SELECT EMPID,
INTO :E1 SEPERATED BY “ , ”

FROM dset;
QUIT;

%PUT &E1;

You could also save numbered macro variables and a &varnum (number of datasets saved as a variable) and do an append within a loop (say you have the datasets listed var1 to varx):

*needs to be in a macro;
%macro  loop_through();
    %do i = 1 %to &Varnum;

       /* proc append code here with data = &&var&i 
    (etc, &&var&i will resolve to &var1, &var2 and so on) */

    %end;
%mend;

%loop_through();