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:

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:

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:

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 executed 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:

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:

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