DATA Step, Macro, Functions and more

Datasets in Library

Reply
New Contributor
Posts: 2

Datasets in Library

What is the most efficient to create a dataset that has the names of all datasets in a given library?

Super User
Posts: 19,770

Re: Datasets in Library

Querying dictionary.tables

Super User
Posts: 11,343

Re: Datasets in Library

An example:

proc sql;

    create table WorkDatasets as

   select memname

   from dictionary.tables

   where libname='WORK'

   ;

QUIT;

Super User
Posts: 3,250

Re: Datasets in Library

Sometimes dictionary tables perform slowly because there are lots of libraries and tables and/or some libraries point to external databases. PROC DATASETS can be a lot faster. This example uses ODS to create a dataset CONTENTS containing a list of all tables in the WORK library.

proc datasets library = WORK nolist;

  contents data = _ALL_ nods;

  ods output members = contents (rename = (name = memname));

  run;

  ods output close;

quit;

Ask a Question
Discussion stats
  • 3 replies
  • 190 views
  • 0 likes
  • 4 in conversation