Seven steps for avoiding (data) hangovers

In a production environment, where dozens of SAS programs are run in sequence, often monthly or quarterly, and where logs can span thousands of lines, it’s easy to overlook the small stuff that can cause data hangovers.  Recognize any of these?

A temporary data set finds its way into subsequent programs (this can also happen with macros and global macros ...)

You ran all 30 of your programs, reviewed the log, and then forgot to save it …

You ran your programs and just overwrote the output from last quarter …

You just sent the wrong output to your customer!

Is your head starting to hurt yet? At the Western Users of SAS Software (WUSS) conference in San Francisco, Mary Rosenbloom kindly offered up some simple housekeeping techniques you can use to avoid hangovers, slip-ups and other programming headaches.

Rosenbloom’s core message was “clean house” with good programming style, meaning:

Using meaningful variable and routine names.

Good program structure.

Straightforward and easily understandable code techniques.

Clear code layout (or visual structure).

Minimization of control-flow.

Steps to clean house:

Use PROC DATASETS to Clear Temp Datasets at the End of a Program

Use PROC CATALOG to Delete Unwanted Macro Programs

Use %SYMDEL to Delete Unneeded Global Macro Variables

Use DM Statements to Save the Log

Save and restore startup (initialized) system options

Use X Commands to Zip your Output

Email the Results using SAS

For step-by-step instructions for each of the seven tips above, check out Rosenbloom’s paper, co-authored with Kirk Paul Lafler: Best practices: Clean house to avoid hangovers.

These code examples are provided as is, without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.

Seven steps for avoiding (data) hangovers was published on SAS Users.