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. There are only three python utilities at this time. As more are added they be added to the main python page on this site.

Usage

Assuming this program is executable, and the line ends match your OS (Unix: LF, Windows LFCR, Mac CR) its commandline is: cklg.py [-h] [-l] [SAS log filename...] where:

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


~/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: Tue Mar 17 14:02:02 EDT 2026