Many years ago I shared a custom task that allows you to view and manage SAS catalogs within SAS Enterprise Guide. As a reminder, a SAS catalog is a special type of SAS file that acts as a container, like a folder, for a variety of content items called catalog entries. Conceptually, this is like a folder in a file system with a diverse collection of file types. The entries and their uses are specific to SAS, and they include things like SOURCE (program code), SCL (SAS Component Language) programs, SAS format definitions, compiled SAS macro programs, and more.
Most catalog entries aren't that interesting for SAS Enterprise Guide users -- with the notable exception of SAS format definitions. Beginning with the day that I shared the task on my blog, my readers began asking for the ability to see inside a SAS format definition. I replied, "great idea! I'll put that on my to-do list." Here it is, 7 years later -- and I've got it done. I am a man of my word.
>> Download the task from here (ZIP file, with README text file instructions)
Pay special attention to the README instructions to deploy the correct version, and make sure you unblock the task DLL if needed.
And more good news -- this task is scheduled to ship as a built-in task (on the Tools menu) in the next release of SAS Enterprise Guide, coming soon. The custom task download will support SAS Enterprise Guide versions 4.3 through 7.13. Later versions will have the task already available!
Key features of the Catalog and Formats Explorer
Like the original task that I shared, this revised task allows you to explore SAS libraries and the catalogs that they contain. You can view the metadata about every catalog entry -- name, type, description, created and modified dates. You can also delete entries that you need to clean up. And you can view the contents of certain types of entries, mainly SOURCE entries and the format entry types. Here are the main enhancements:
- You can view the contents of FORMAT, FORMATC, INFMT, INFMTC entries
- The window displays “modeless” – you can have it showing while you still work on other tasks, such as your SAS programs. Define a format in code, run it, and then click Refresh in the task to see it.
- You'll find special entry for "User-defined formats", which shows just the catalogs that contain format definitions within the FMTSEARCH path. You can still navigate any library to find catalogs that contain formats.
Here's a screenshot of the task. You can also watch my 5-minute video demonstration of the task in action on SAS Support Communities.
For developers: How it was built
Since the original task was shared as a companion example for my custom tasks book, I've also shared the source code that goes into these enhancements. You can find these in the same GitHub repository that contains the original version. Adding these enhancements makes use of other techniques that I've already shared on this blog.
To generate a text report of a format definition, the task submits a PROC FORMAT step with a SELECT statement. Here's an example:
filename fmtout temp; %let _catexp1 = %sysfunc(getoption(center)); %let _catexp2 = %sysfunc(getoption(date)); %let _catexp3 = %sysfunc(getoption(number)); %let _catexp4 = %sysfunc(getoption(pagesize)); options nocenter nodate nonumber pagesize=max; ods listing file=fmtout; proc format fmtlib lib=dbmlnx.formats; select ab; run; ods listing close; options &_catexp1. &_catexp2. &_catexp3. PS=&_catexp4.;
With the listing file generated, the task uses code similar to this Windows PowerShell example to download the contents of the output. You might notice that the SAS code sets a few system options, but it stores and later replaces the option values so that your other programs won't be affected.
If you like to tinker, feel free to download the source code and see how it works. If you want to learn more about custom tasks in SAS Enterprise Guide, view my Ask the Expert session, available on-demand from here.
The post Viewing SAS catalogs and formats in SAS Enterprise Guide appeared first on The SAS Dummy.