Return to Homepage

Goto the Tip of the Month Archive

Other interesting pages ...
LinkedIn Profile
SAS Cheat Sheet
Useful SAS Code
Full SAS Example
Basic Statistics
Contact Information

SAS Tip of the Month
November 2015
(for SAS)

One of those very important lessons you learn as a programmer starting out, particularly in our field, is to ALWAYS run your production code in batch mode, not interactive mode. A skilled programmer will almost always write their code in such a way that the program will not produce output unless you are in batch mode.

The first reason is that it makes sure that there are no dependencies lurking about that may cause an issue, e.g.

   %let foot2=Source &pgm Created &sysdate9.;
   %let pgm=T14.2.1;

This example was from an actual program, amended to protect those who wrote the code and those who QCed the program. What you may ask is wrong with this? The value of macro variable PGM is set AFTER it is used in the FOOTNOTE2 macro variable, so it actually is not assigned on the first time around, but if you run the program a second time while in interactive mode the macro variable PGM is already set so is available in the FOOTNOTE2 macro variable – the issue is not detected.

A second reason is that it will produce a clean LOG file showing what was initiated when the SAS program started, what was run and the actual output from each step, and when it was run (SAS in interactive mode has an internal date and time of the session start, not the time of program run, unless you do a trick or two).

The third reason is that any program must be able to be reproducible at any time – a client or regulatory review can ask you as a SAS programmer run the program and months after it was run and then check that the output is the same, except of runtime dates.

This last item is a debatable item, but the most important file for any archive is the SAS LOG – from it you can get the date and time the program is run, what was run, and be able to recreate the program from it.

Hope this was useful.

Updated November 2, 2015