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:

  1. Use PROC DATASETS to Clear Temp Datasets at the End of a Program
  2. Use PROC CATALOG to Delete Unwanted Macro Programs
  3. Use %SYMDEL to Delete Unneeded Global Macro Variables
  4. Use DM Statements to Save the Log
  5. Save and restore startup (initialized) system options
  6. Use X Commands to Zip your Output
  7. 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.


About Author

Anne-Lindsay Beall

Editor-in-Chief, sascom magazine

Anne-Lindsay Beall is Editor-in-Chief of sascom magazine, Editor of the Customer Intelligence Knowledge Exchange at SAS, and Editor of the SAS Retail News. She has developed a comprehensive portfolio of business and marketing communications during her career spanning 14 years of magazine and marketing work. You can find her on Twitter: @annelindsayb or on LinkedIn at:

Related Posts

Back to Top