2
votes

I created a few hundred temporary data sets with the use of a macro. All the data sets start with the same prefix, 'Legal_' in this case.

Once I have combined the data sets, I would like to drop the temporary tables created by the macro.

  DATA COMBINE_LEGAL_FEES;
    SET LEGAL_:;
  RUN;

How do I drop all the temporary data sets without listing each individual data set? The 'prefix:' method used in the DATA step does not work in a PROC SQL step.

PROC SQL;
    CREATE TABLE All_Transactions AS
        SELECT
            T1.*,
            T2.LEGAL_FEES

        From CCAREP.SAS_201401TO201602 T1
        LEFT JOIN WORK.COMBINE_LEGAL_FEES T2 ON (T1.ACC_NUM = T2.ACC_NUM)
        ;
    DROP TABLE LEGAL_: ;
QUIT;

There are just too many temporary tables to list them all.

Thanks Suavis

2

2 Answers

7
votes
proc datasets library=work memtype=data nolist;
    delete legal_:;
run; quit;
0
votes

Christos Avrillionis' answer is very elegant, but I'd still like to mention the existence of the dictionary system tables.

PROC SQL;
  CREATE TABLE legal_tables AS
  SELECT
    *
  FROM
    dictionary.tables
  WHERE
    libname = 'WORK' and
    memname like 'LEGAL%'
;
QUIT;

With this list of tables, you can use whatever favorite method you'd like to start deleting them.

I don't have my SAS license at the home, so I haven't tested my code above.