About CheckLog‎ > ‎Documentation‎ > ‎

Header

    /********************************************************************************
       BEGIN MACRO HEADER
     ********************************************************************************

        Name:       CheckLog
        Author:     Christopher A. Swenson
        Contact:    Chris@CSwenson.com
        Created:    2009-08-28
        Version:    3 (2012-04-02)

        OS:         Microsoft Windows, UNIX, OpenVMS, z/OS
        SAS:        9.1.3+
        Language:   English

        Sections:   0) Macro Header                     4) Internal Programs
                    1) Log Settings                     5) Determine Log(s) to Check
                    2) Macro Variables                  6) Import and Check Log(s)
                    3) Check Arguments                  7) Report Issues

        Purpose:    Check log(s) for issues, including lines with (e)rror, (w)arning,
                    (i)nvalid, or (u)ninitialized messages. Additionally, other
                    phrases associated with issues are checked, and specific phrases
                    are ignored. The macro can also be used with non-SAS logs, as
                    long as the log uses the same issue keywords.

        Disclaimer: This program is provided "as-is". The user is responsible for
                    testing the software on their platform and selecting appropriate
                    recipients for email output. The user agrees that the author
                    will not, under any circumstances, be held accountable for any
                    damages of any type that result from using this software.

        Usage:      The output of the macro can provide information about where to
                    find issues in the log. When issues are identified, it is best
                    to open the original log and program to identify the source of
                    an issue. Otherwise, the Log data set contains all lines with the
                    Ignore and Found variables.

                    It is suggested that the user saves the log at about the same time
                    as using the CheckLog macro, especially if relying on the email
                    function for communication. The original log can then be reviewed
                    at a later time. This can be accomplished by using a DM statement
                    (see below) or copying the Work.log file from the work directory
                    to a permanent directory once CheckLog has run.

                    dm log "file 'C:\Example\Log_20100801.log' replace;" wpgm;

                    This macro can be set to a keyboard shortcut in SAS to check the
                    current log. It has worked most consistently on F5-F8 combinations.
                    I suggest setting it to SHF + F6, since F6 is the key for the
                    log window. Type the following text in the keyboard shortcut
                    definition: gsubmit '%checklog;'

        Batch Mode: During batch mode, be sure to execute a DATA step or a procedure
                    before using CheckLog. Otherwise, the log will not be written out
                    when CheckLog tries to make a copy of it.

        Enterprise: Using Enterprise Guide, the user must either use PROC PRINTTO to
                    export the log to a specific location or export the log as a step
                    in the project.

        Log names:  The names of the logs should be valid SAS names, so as to name
                    the data sets of the imported text.

        Output:     Data Sets:

                    Log             - The imported log (named according to code
                                      if reviewing a directory)
                    Log_Issues      - The log filtered for identified issues.
                    Log_Keywords    - The log with keywords, including ignored
                                      messages. Only output during testing.
                    Log_Summary     - A summmary of the issues in a log, generated
                                      for the output email.
                    Logs_w_Issues   - A list of all the logs checked in a directory
                                      that contained issues.

                    Macro Variables:

                    logmsg - A message that conveys the status of what was checked
                    issues - A count of issues discovered

        (C)aution:  Do not directly use the issue words that the macro is looking for.
                    Mask these words by using parentheses, underscores, character
                    replacement, or some other technique. If a conditional (E)RROR
                    or (W)ARNING is necessary, use the %str() function. Here are some
                    examples:

                    * Comment: Check for (e)rrors before continuing. ;
                    * Sometimes w_arnings are generated here. ;

                    data _null_;
                        [other statements]
                        if problem=1 then put "%str(E)RROR: There are problems.";
                    run;

                    %put %str(E)RROR: This is a custom message.;

        Arguments:  All arguments are optional. If no options are specified, the
                    macro checks the current log and outputs issues to Log_issues.

                    Input:

                    log     - Directory of logs or full pathname of a log. Do not use
                              single or double quotes. Note that the names of the
                              logs in a directory should be valid SAS names.

                    ext=    - Extension to search for when looking for logs in a
                              directory of log, defaulted to LOG.

                    subdir= - Search subdirectories using the DirList macro. This
                              macro can only be used on Microsoft Windows.
                              N = Do not search subdirectories (default)
                              Y = Search subdirectories (requires DirList macro)

                    keyword=- A list of word or words to search for in the log text,
                              which identify issues beyond those already identified
                              in this macro. This can be used to add words for non-
                              SAS logs that may use additionally words to indicate
                              issues, for example, (C)AUTION or (A)LERT. This could
                              also be used to differentiate user-specified issues
                              from system-generated issues.

                              NOTE: The order of the words listed matters. The words
                              listed first will be searched for last, and will
                              overwrite any other words found prior. Thus, the
                              first word should have the highest priority. Of course,
                              the original keywords will overwrite user-specified
                              keywords.

                    exclude=- A data set containing issues to exclude. Include the
                              name of the variable after the data set name if it is
                              not LogText (e.g., work.exclusions list). This can be
                              used when non-issues are encountered that cannot be
                              filtered based on a simple rule (e.g., a data set name
                              unavoidably contains the word '(e)rror'). It is not
                              recommended that this feature be used to circumvent
                              code revision for easily-avoided issues. Note that data
                              set options can be applied with this argument, so a
                              master file with exclusions can be used and filtered.

                    Reporting:

                    out=    - Name of the output issues data set (default: Log_issues).
                              Note: This is automatically set when checking a
                              directory of logs.

                    pm=     - Determines whether or not the pop-up message is used:
                              N = No, never display a pop-up message
                              Y = Yes, always display a pop-up message (default)
                              E = (E)rror only pop-up message

                    sound=  - Determines whether or not a sound is played:
                              N = No, never play a sound (default)
                              Y = Yes, always play a sound
                              E = (E)rror only sound

                    to=     - Email address(es) to send the results to.
                              Note: Email support must be set up in SAS to use
                              this function.

                    cc=     - Email address(es) to carbon copy the results to.
                              Note: CC will not work without the TO argument.

                    relog=  - Overwrites the current log with the imported log, after
                              the CheckLog outputs notes regarding the status of the
                              log. Best used for testing and reviewing logs.
                              N = Do not overwrite the current log
                              Y = Overwrite the current log with the imported log
                              E = (E)rror only overwrite

                    Operational:

                    dirext= - When checking a directory of logs, it adds the directory
                              and extension to the log name.
                              N = No, do not add directory and extension
                              Y = Yes, add directory and extension

                    shadow= - Make a copy of the log before checking it, useful when
                              the program is still running and generating the log.
                              N = No, do not make a copy of the log (default)
                              Y = Yes, make a copy of the log

                    abort=  - Determines whether or not the following program is
                              aborted. This is useful to halt a long program and
                              (a)lert the user that there are issues.
                              N = No, do not abort program when issues occur (default)
                              Y = Yes, abort program when issues occur

                              (C)AUTION: This option may have undesirable results.
                              Please use it with care and thorough testing. In version
                              9.1.3, it has been identified that when the abort option
                              is specified and used in a program, then the CheckLog
                              macro is used from a keyboard shortcut, SAS crashes.
                              There is no known workaround and it appears to be a bug
                              in SAS 9.1.3.

                              MACROS: For use in macros, it is much more stable to
                              use the following statement to end the program
                              immediately after using the CheckLog macro:

                              %if &ISSUES>0 %then %return;

                    test=   - Set to 'test' (i.e., test=test) to test CheckLog
                              without turning off the log within the macro.
                              Additionally, the data set log_keywords is output
                              for troubleshooting.

        Issues:     The following statements are considered issues. Note that the
                    statements have been broken up to avoid detecting them within
                    this program.

                    Keywords:
                    - (E)RROR (macro variable: iss1)
                    - (W)ARNING (macro variable: iss2)
                    - (I)NVALID (macro variable: iss3)
                    - (U)NINITIALIZED (macro variable: iss4)

                    Conversion:
                    - CHARACTER VALUES HAVE BEEN CON-VERTED TO NUMERIC VALUES
                    - NUMERIC VALUES HAVE BEEN CON-VERTED TO CHARACTER VALUES

                    Format:
                    - AT LEAST ONE W.D FOR-MAT

                    Graph:
                    - OUTSIDE THE AX-IS RANGE

                    Input:
                    - LOST CA-RD (input/infile data step)
                    - NEW LI-NE WHEN INPUT
                    - ONE OR MORE LINES WERE TRUNC-ATED (PROC IMPORT issue)

                    Math:
                    - DIVISION BY ZE-RO DETECTED
                    - MATHEMATICAL OPER-ATIONS COULD NOT BE PERFORMED
                    - MIS-SING VALUES WERE GENERATED

                    Merge:
                    - ME-RGE STATEMENT HAS MORE THAN ONE DATA SET WITH RE-PEATS
                      OF BY VALUES

                    SQL:
                    - THE EXECUTION OF THIS QUERY INVOLVES PERFORMING ONE OR
                      MORE CAR-TESIAN PRODUCT JOINS THAT CAN NOT BE OPTIMIZED.
                    - THE QUERY REQUIRES RE-MERGING SUMMARY STATISTICS BACK WITH
                      THE ORIGINAL DATA

                    Syntax:
                    - A CASE EXPRE-SSION HAS NO ELSE CLAUSE
                    - THE MEANING OF AN IDENT-IFIER AFTER A QUOTED STRING MAY CHANGE

                    Additional phrases for review are listed below.

                    - "NO TOOLS DEFINED"
                    - "UNABLE TO ACCESS SPECIFIED PRINTER DRIVER"
                    - "UNABLE TO FIND THE PRINTER NAME"
                    - "HAS 0 OBSERVATIONS" (Note: This could be intended.)
                    - "INPUT DATA SET IS EMPTY" (Note: This could be intended.)
                    - "MULTIPLE LENGTH" (I think this is usually an (e)rror.)
                    - "A MISSING EQUAL SIGN HAS BEEN INSERTED"
                    - "A GROUP BY CLAUSE HAS BEEN DISCARDED"
                    - "DUPLICATE BY VARIABLE(S) SPECIFIED"
                    - "DUPLICATION OF BY VARIABLE" (Note: See phrase above.)

                    Check the following pages:
                    - http://tinyurl.com/3wrvozg (sas.com)
                    - http://tinyurl.com/3qe2ugs (sas.com)
                    - http://tinyurl.com/3bn7h3n (sas.com)

        Ignored:    The following statements are ignored. These statements are either
                    common or are not always issues. For example, issues generated
                    from libname statements may or may not affect the current code.
                    These issues are ignored since they will present other issues if
                    necessary for the current code. Note that the statements have been
                    broken up to avoid detecting them within this program.

                    Variable messages:
                    - _(E)RROR_=0
                    - IF _(E)RROR_
                    - SET (E)RROR DETECTION MACRO
                    - SET THE (E)RROR DETECTION MACRO

                    SAS messages:
                    - THE MACRO... COMPLETED COMPILATION WITHOUT (E)RRORS
                    - YOUR SYS-TEM IS SCHEDULED TO EXPIRE ON
                    - (E)RROR(S) PRINTED ON PAGE
                    - (U)nable to copy SASUSER registry to WORK registry. Because of this,
                    - you will not see (r)egistry customizations during this session.

                    Library messages:
                    - (E)RROR IN THE LIBNAME STATEMENT
                    - ONLY AVAILABLE TO USERS WITH RE-STRICTED SESSION PRIVILEGE
                    - THE AC-COUNT IS LOCKED
                    - UN-ABLE TO CLEAR OR RE-ASSIGN THE LIBRARY
                    - UNABLE TO COPY SAS-USER REGISTRY TO WORK REGISTRY
                    - USER DOES NOT HAVE APP-ROPRIATE AUTHORIZATION LEVEL FOR