7.5 - Types of Log Messages

7.5 - Types of Log Messages

When you are trying to write programs that work, you'll no doubt encounter some messages in the log window that you'll need to interpret to figure out what SAS is trying to tell you. In this section, we investigate three different kinds of messages —errors, warnings, and notes — that SAS displays in the log window.

Example 7.7: ERROR Messages

In general, when SAS displays ERROR messages in your log window — in red as illustrated — your program will not run because it contains some kind of syntax error or spelling mistake.

The following code causes SAS to print an ERROR message in the log window:

DATA one;
  input A B C;
	DATALINES;
	1 2 3
	4 5 6
    7 8 9
	;
RUN;

PROC PRINT / DATA = one;
RUN;

First, launch and run  the program, and then look in the log window to see the ERROR message that SAS displays:

  PROC PRINT / DATA = one;
                -
                22
                200
NOTE: Writing HTML Body file: sashtml1.htm
ERROR 22-322: Syntax error, expecting one of the following: ;,
              BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL,
              GRANDTOT_LABEL, GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL,
              HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS,
              SPLIT, STYLE, SUMLABEL, UNIFORM, WIDTH.
ERROR 200-322: The symbol is not recognized and will be ignored.
  RUN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.50 seconds
      cpu time            0.31 seconds

as a result of the inappropriately placed forward slash (/) in the PROC PRINT statement.

Example 7.8

The location of an error is typically easy to find because it is usually underlined, but it is often tricky trying to figure out the source of the error. Sometimes what is wrong in the program is not what is underlined in the log window but something else earlier in the program. The following program illustrates such an event:

DATA one;
    INPUT A B C
	DATALINES;
	1 2 3
	4 5 6
	7 8 9
	;
RUN;

First, review the program and note that the problem with the code is that the INPUT statement is missing its required semi-colon (;). Then, launch and run  the program, and then look in the log window to see the ERROR message that the code produces:

  DATA one;
      INPUT A B C
      DATALINES;
      1 2 3
        -
        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

      4 5 6
      7 8 9
      ;
  RUN;

ERROR: No DATALINES or INFILE statement.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.ONE may be incomplete.  When this step was
         stopped there were 0 observations and 4 variables.
WARNING: Data set WORK.ONE was not replaced because this step was
         stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

You should see that SAS underlines the 1 in the first data line rather than the end of the INPUT statement. The moral of the story here is to not only look at what SAS underlines but also at the few lines of code immediately preceding the underlined statement.

Example 7.9: WARNING Messages

When SAS displays WARNING messages in your log window — in green as illustrated — your program will typically run. A warning may mean, however, that SAS has done something that you didn't intend. It is for this reason that you'll always want to check the log window after submitting a program to make sure that it doesn't contain WARNING messages about the execution of your program.

The following code results in SAS printing a WARNING message in the log window:

DATA example2;
   IMPUT a b c;
   DATALINES;
112 234 345
115 367   .
190 110 111
;
RUN;

As you can see by the red-colored font displayed in the (Enhanced) Program Editor, the keyword INPUT has been incorrectly typed as IMPUT. If you don't catch the misspelling in the Program Editor, SAS will, whenever possible, attempt to correct your spelling of certain keywords. In these cases, SAS prints a WARNING message in the log window to alert you to how it interpreted your program in order to get it to run.

Launch and run  the program, and then look in the log window to see the WARNING message:

  DATA example2;
     IMPUT a b c;
        -----
        1
WARNING 1-322: Assuming the symbol INPUT was misspelled as IMPUT.

     DATALINES;

NOTE: The data set WORK.EXAMPLE2 has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

that the code produces. Note, too, that in spite of the WARNING message, SAS is still able to complete the DATA step by changing the spelling of IMPUT to INPUT.

Example 7.10: NOTE Messages

NOTE messages, which are displayed in blue as illustrated, are less straightforward than either warnings or errors. Sometimes notes just give you information, like telling you the execution time of each step in your program. Sometimes, however, a NOTE can indicate a problem with the way SAS executes your program.

The following code results in SAS printing a NOTE in the log window:

DATA example2;
   INPUT a b c;
   DATALINES;
112 234 345
115 367
190 110 111
;
RUN;

Launch and run  the program, and then look in the log window to see the NOTE that the code produces:

  ;
  RUN;

  DATA example2;
     INPUT a b c;
     DATALINES;

NOTE: SAS went to a new line when INPUT statement reached past the end
      of a line.
NOTE: The data set WORK.EXAMPLE2 has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


  ;
  RUN;

You should see that SAS appropriately warns you that it went to a new line when the INPUT statement didn't find the third data value in the second data line. Incidentally, you can correct this problem either by adding the following line of code just before the INPUT statement:

INFILE DATALINES MISSOVER;

or by adding a missing value (.) to the end of the second data line.

Example 7.11

Beware that not every NOTE that appears in the log window is a problem. The following code is an example in which SAS going to the new line is exactly what is wanted:

DATA example2;
   INPUT a b c;
   DATALINES;
101
111
118
215
620
910
;
RUN;

PROC PRINT data = example2;
RUN;

Obs

a

b

c

1

101

111

118

2

215

620

910

In this case, the programmer purposefully entered one data value in each record. As long as it is what the programmer intended, SAS will go to a new line in each case and thereby read in 2 observations with 3 variables. Launch and run  the program. Then, review the output to understand how SAS read in the data, and then review the log window:

  DATA example2;
     INPUT a b c;
     DATALINES;

NOTE: SAS went to a new line when INPUT statement reached past the end
      of a line.
NOTE: The data set WORK.EXAMPLE2 has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


  ;
  RUN;
  PROC PRINT data = example2;
  RUN;

NOTE: There were 2 observations read from the data set WORK.EXAMPLE2.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

to see that the NOTE about SAS going to a new line when the INPUT statement reached past the end of a line is just what the doctor ordered.


Legend
[1]Link
Has Tooltip/Popover
 Toggleable Visibility