Reading the log: SAS is telling you something

0

Contributed by Chris Hemedinger, coauthor of SAS for Dummies, Second Edition, the genius behind The SAS Dummy blog, and the moderator of the SAS Enterprise Guide discussion forum.

The SAS log is your source for information if you want to know the following:

  • What SAS did while running your program
  • How much time it took to run the program
  • What, if anything, went wrong
  • If your SAS program was a CSI episode, the SAS log would be like that magic black light that reveals the yucky evidence at the crime scene. When the program fails to run as expected and you need to know where things went awry, the SAS log is your primary forensics tool.

    The most common element that people look for in the SAS log is the ERROR line. If there is a syntax or processing error, SAS spits out one or more ERROR lines that are usually colored a telltale shade of red. In SAS Enterprise Guide, a program that runs with an error is branded with a "scarlet X" on the program icon.

    Here is an example of a common SAS error, caused by using the
    wrong name for a variable in a data set:

    15         proc means data=sashelp.class;
    16         var gender;
    ERROR: Variable GENDER not found.
    

    Most SAS error messages are self-explanatory. But if you encounter an error message that you can’t decipher, don't despair! Visit the SAS support Web site at support.sas.com and paste the message into the search window. Chances are good that you'll find a few usage notes about the conditions that can cause the particular error.

    After you've solved all the errors in your program, don't forget to investigate any WARNING lines that persist in the log. In SAS Enterprise Guide, a program that contains WARNING lines in the log shows a little yellow triangle (the international warning symbol) in the program icon. A warning is less severe than an error because your program ran to completion. However, the warning messages might reveal that things weren't processed as you expected.

    Here is an excerpt from a log that shows a misspelling that SAS has attempted to work around, generating a warning:

    35         proc means data=localCars
    36           mean stddev medion mode n;
                             ____
                             1
    WARNING 1-322: Assuming the symbol MEDIAN was misspelled as medion.
    

    Finally, if everything is running well and you just want to dig into some of the processing details,
    SAS logs are peppered with NOTE lines that report on how much data was processed and
    how long the processing took. Here is an example of a typical note:
    <br />
    NOTE: There were 19 observations read from the data set SASHELP.CLASS.<br />
    NOTE: PROCEDURE MEANS used (Total process time):<br />
          real time           0.06 seconds<br />
          cpu time            0.03 seconds<br />
    

    It's an excellent practice to ensure that your programs can run free of warnings and errors.
    Some SAS programmers who work in tightly regulated industries must show their SAS log output to prove that their programs run cleanly.

    Chris' tip is from "Chapter 16: SAS Programming for the Faint of Heart" in SAS For Dummies, Second Edition.

    Share

    About Author

    Chris Hemedinger

    Director, SAS User Engagement

    +Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies

    Comments are closed.

    Back to Top