Friday, April 15, 2016

Hack 3.3 Creating a Detailed Contents Listing of A SAS Catalog


SAS Programming Professionals,

Did you know that you can create a detailed listing of the contents of a SAS catalog?

To do so, simply specify the CONTENTS statement in the CATALOG procedure.  This can come in handy when you receive a catalog from out-of-house that is ostensibly a format catalog associated with variables in an attendant SAS data set.  

You can determine what, exactly, is in the catalog by running PROC CATALOG thusly:

      libname newproj "H:\newproject\inputlib";

      proc catalog catalog=newproj.myfmts;
           contents stats;
      quit;

The CONTENTS statement instructs SAS to display the objects stored in the catalog.  The STATS option directs SAS to provide all of the statistics available for the entries in the format catalog.  Without the STATS option, a more abbreviated table is created.
Running the CATALOG procedure shows that the catalog I received contains only two formats:

Contents of Catalog NEWPROJ.MYFMTS
#
Name
Type
Create Date
Modified Date
Description
Page
Size
Block
Size
Num of
Blocks
Last
Block
Bytes
Last
Block
Size
Pages
1
AGEGROUP
FORMAT
22Jun14:12:51:45
22Jun14:12:51:45
 
4096
4096
1
245
510
1
2
GENDER
FORMATC
22Jun14:12:51:45
22Jun14:12:51:45
 
4096
4096
1
219
255
1

  …and I was expecting one format for each of the 427 variables in the SAS data set they sent.  So, I will have to contact the sender with news of my own QC of the format catalog they sent!

Best of luck in all your SAS endeavors!

----MMMMIIIIKKKKEEEE
(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.

No comments:

Post a Comment