DATA Step, Macro, Functions and more

List all dataset names in a library

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

List all dataset names in a library

Good Day! I am using using SAS Essentials, by Elliot and Woodward, to get my feet wet with SAS. The following code displays a list of the data after importing the file somedata (in the directory it is somedata.sas7bdat):

*******************************************************
* From SAS ESSENTIALS, Jossey Bass/Wiley              *
* (C) 2010 Elliott, Alan C. and Woodward, Wayne A.    *
*******************************************************;
PROC DATASETS;
CONTENTS DATA= "/folders/myfolders/sasdata/somedata";
RUN;

 

However, the authors say to display information about all data sets in the  sasdata library I should

CONTENTS DATA= "/folders/myfolders/sasdata/somedata._ALL_";but I do

 

PROC DATASETS;
CONTENTS DATA= "/folders/myfolders/sasdata/sasdata._ALL_";
RUN;

 

Log is:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 *******************************************************
57 * From SAS ESSENTIALS, Jossey Bass/Wiley *
58 * (C) 2010 Elliott, Alan C. and Woodward, Wayne A. *
59 *******************************************************;
60 PROC DATASETS;
61 CONTENTS DATA= "/folders/myfolders/sasdata/sasdata._ALL_";
ERROR: Extension for physical file name "/folders/myfolders/sasdata/sasdata._ALL_" does not correspond to a valid member type.
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
62 RUN;
 
NOTE: Statements not processed because of errors noted above.
63
64
65 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
77
 
Any suggestions?
  Most appreciative
 
PS I am using SAS University ed on Windows 7 VM Virtual Box Manager

Accepted Solutions
Solution
‎08-08-2016 05:55 PM
Super User
Posts: 19,770

Re: List all dataset names in a library

Usually the notation suggestion is LIBNAME._all_

 

So your code should look like the following, assuming your libname is correct. Note that proc datasets requires a QUIT. 

 

libname mylib '/folders/myfolders/sasdata/sasdata';

PROC DATASETS;
CONTENTS DATA= mylib._all_;
RUN;QUIT;

View solution in original post


All Replies
Super User
Posts: 19,770

Re: List all dataset names in a library

The book lists notations like in your code, including the portion in blue?

 

PROC DATASETS;
CONTENTS DATA= "/folders/myfolders/sasdata/somedata";
RUN;

Occasional Contributor
Posts: 6

Re: List all dataset names in a library

No Sir. I had to modify the original file location because I am using the University Edition, and as you are well aware, I have to put all my files (and subdirectories, ie. sasdata) where they are to be accesible to Virtual box. the original code was:

DATAFILE= C:\SASDATA\SOMEDATA;

 

Hope this answers your question and most appreciative for any assistance

Super User
Posts: 19,770

Re: List all dataset names in a library

Not a Sir. 

 

Occasional Contributor
Posts: 6

Re: List all dataset names in a library

Your name is the same as a good friend. My deepest and most sincere apologies!

Super User
Posts: 19,770

Re: List all dataset names in a library

They appear to be using a non-standard convention. I would recommend a different book to learn from. 

 

The Little SAS Book for SAS University Edition is probably a better starting point. 

Solution
‎08-08-2016 05:55 PM
Super User
Posts: 19,770

Re: List all dataset names in a library

Usually the notation suggestion is LIBNAME._all_

 

So your code should look like the following, assuming your libname is correct. Note that proc datasets requires a QUIT. 

 

libname mylib '/folders/myfolders/sasdata/sasdata';

PROC DATASETS;
CONTENTS DATA= mylib._all_;
RUN;QUIT;
Occasional Contributor
Posts: 6

Re: List all dataset names in a library

This works. Most appreciative!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 459 views
  • 1 like
  • 2 in conversation