cklg.py -- Scan a SAS log for errors, warnings, and other issues


This is a conversion of cklg.pl to python. 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 utility is part of a collection of more text-processing tools.

Usage

Assuming this program is executable, its commandline is: cklg.py [-h] [-l] [SAS log filename...] where:

As an example, the command cklg testdate2.log might produce output like:


> cklg.py ~/testdate2.log
: No such file or directory
(latte 2:44pm) knassen: ~/sas> python3 cklg.py ~/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 Python Page
Last Modified: Fri Jan 2 12:19:22 EST 2026