Monday, May 2, 2016

Hack 3.4 Creating a Detailed Directory Listing of Files in A SAS Data Library

SAS Programming Professionals,

Did you know that you can get a detailed directory listing of the files in a SAS data library without having to print all of the detail information for each and every SAS data set in it? 

The listing is called "Library Members" and contains the following information: 

·        Name - Name of the SAS data set, Index, Catalog, etc.

·        Member Type - Data, Index, Catalog, etc.

·        Level - If the SAS data library is composed of concatenated directories, this is the concatenation level at which this file can be found

·        Obs, Entries, or Indexes - The number of observations for a SAS data set, entries for a SAS catalog, and indexes for an index file

·        Vars - Number of variables for a SAS data set

·        Label - The file’s label

·        File Size - Size of the file

·        Last Modified - Date-time stamp of when the file was last modified

This is great information to have if you need to conduct a quick visual inspection of a SAS data library you are not familiar with.

Here is code to produce a Library Members listing:

proc contents data=sashelp._all_ memtype=data details nods;

The DETAILS option enables the more detailed "Library Members" listing and the NODS option turns off that pesky listing of individual data set details.

Because of its size, it is not really practical to print the output to the PROC CONTENTS above in this blog.  Copy it into a SAS program and execute it to see the wealth of information that is available about the members of a SAS data library.

Best of luck in all your SAS endeavors!

(aka Michael A. Raithel)

Excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers
I plan to post each and every one of the hacks in the book to social media on a weekly basis.  Please pass them along to colleagues who you know would benefit.