cklg.pl -- Scan a SAS log for errors, warnings, and other issues
I wrote this Perl program to do a faster scan through one or more SAS log files than I could do by pulling them into an editor and paging through them. The script, on Unix/Linux, can be run on multiple log files. The output is set up to allow the use of the Vim editor's Quick Fix facility. Adding more search terms is easy. Just add them to the @search array like the others.
- This program is intended to be run from a Unix or Linux command line.
- Output is sent to STDOUT, so redirect it to a file to save it.
- Not all issues this program finds are labeled as errors or warnings. For example, "0 observations" may be expected or not, depending on your program and data. The programmer must check potential issues like this to make sure they are not truly issues.
- The program uses a case-insensitive search (so errors and :ERROR and Error all get found, for example)
- The output is formatted so that it can be used with Vim's QuickFix facility.
- Show cklg code
- Download: cklg.pl
Usage
Assuming this program is executable, its commandline is: cklg.pl [-h] [-l] [SAS log filename...] where:
- -h Display this usage message
- -l List the search terms used by the program
As an example, the command cklg testdate2.log might produce output like:
~/sas> cklg testdate2.log testdate2.log:33:ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, testdate2.log:40:NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). testdate2.log:42:NOTE: The SAS System stopped processing this step because of errors. testdate2.log:43:WARNING: The data set WORK.TEST2 may be incomplete. When this step was stopped there were 0 testdate2.log:45:WARNING: Data set WORK.TEST2 was not replaced because this step was stopped.
The -l command line option will list the search terms used by the program. This allows you to see why a certain issue was found in a log or missed in a log search (so you can add it). I haven't added new terms to this list for a long time. Once I put it into use I found most of the common log issues and some uncommon issues. The term "error" catches a lot of issues beyond the usual SAS :ERROR tags in the log. the cklg -l output looks like this:
~/sas> cklg -l The log search terms used by cklg are: error fatal warning: syntax error converted uninitialized 0 obs no obser [...] stopped due to loop 29 terms defined.
Back to Kent's Perl Page
Last Modified: Mon Aug 4 09:34:50 EDT 2025