7.1 SAS Log Analysis & Diagnostic Messages

Key Takeaways

  • The SAS log records the execution history, line numbers, processing times, dataset observation counts, and diagnostic messages for every SAS step.
  • SAS diagnostic messages fall into three distinct severity categories: NOTE (informational message), WARNING (non-fatal execution issue or syntax concern), and ERROR (fatal syntax error or unrecoverable processing error).
  • Automatic implicit data type conversions generate explicit log notes: SAS logs a NOTE when converting numeric values to character values during string operations or character to numeric during arithmetic operations.
  • Invalid raw data inputs trigger an 'Invalid data' NOTE in the log, set _ERROR_ = 1, assign a missing value (.) to the target variable, and dump the input buffer and PDV contents to the SAS log.
  • System options such as NOTES/NONOTES, SOURCE/NOSOURCE, and PROC PRINTTO allow developers to suppress log output or redirect execution logs to external files for automated auditing.
Last updated: August 2026

7.1 SAS Log Analysis & Diagnostic Messages

The SAS log is the primary diagnostic window for every SAS programmer. When a SAS program executes, SAS records every statement parsed, every dataset created, observation counts, execution times, and—most importantly—diagnostic messages detailing how the processing proceeded. On the SAS Certified Specialist: Base Programming exam (A00-231), analyzing log messages, identifying error conditions, and recognizing system message types are heavily tested skills.


1. Structure and Purpose of the SAS Log

Whenever a DATA step or PROC step executes, SAS generates a corresponding entry in the SAS log. The log serves three primary administrative and debugging functions:

  1. Program Audit Trail: Displays the exact source lines executed, preceded by sequential line numbers.
  2. Execution Statistics: Reports dataset creation status, including the library name, dataset name, number of observations, and number of variables.
  3. Diagnostic Reporting: Outputs informational notes, system warnings, and execution error messages.
/* Example SAS Log Output */
1    data work.employee_salaries;
2        set work.raw_employees;
3        annual_bonus = salary * 0.10;
4    run;

NOTE: There were 150 observations read from the data set WORK.RAW_EMPLOYEES.
NOTE: The data set WORK.EMPLOYEE_SALARIES has 150 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

2. SAS Diagnostic Message Hierarchy

SAS categorizes diagnostic log messages into three distinct tiers of severity: NOTE:, WARNING:, and ERROR:.

Message TypePrefixDescription & SAS Execution Behavior
Informational NoteNOTE:Standard feedback confirming successful operations, observation counts, implicit conversions, or raw data issues. Does not stop execution.
System WarningWARNING:Indicates a potential issue or non-fatal anomaly (e.g., dataset specified in DROP statement does not exist, or uninitialized variables). Processing continues, but output may be compromised.
Fatal ErrorERROR:Indicates a severe syntax error, missing dataset, invalid option, or unrecoverable runtime condition. SAS stops processing the current step and enters syntax-check mode.
/* Log example showing a WARNING and an ERROR */
12   proc print data=work.nonexistent_dataset;
ERROR: File WORK.NONEXISTENT_DATASET.DATA does not exist.

13   proc sort data=work.sales;
14       by region dept;
15   run;
WARNING: Variable DEPT not found in data set WORK.SALES.

3. Common Log Notes & Diagnostic Messages

Understanding specific log messages is critical for debugging programs and answering Base SAS exam questions.

A. Implicit Data Type Conversion Notes

When SAS performs implicit data type conversion during execution, it writes explicit notes to the SAS log:

  • Character to Numeric Conversion: Triggered when a character variable is used in an arithmetic operation (e.g., total = char_amount + 50;).
    NOTE: Character values have been converted to numeric values at the places given by:
          (Line):(Column)
          14:18
    
  • Numeric to Character Conversion: Triggered when a numeric variable is used in a character operation or string concatenation (e.g., full_code = dept_num || '-HQ';).
    NOTE: Numeric values have been converted to character values at the places given by:
          (Line):(Column)
          22:21
    

B. Invalid Data Messages & Input Buffer Dumps

When raw data read by an INPUT statement does not match the expected variable type (for example, reading text 'ABC' into a numeric variable), SAS responds with a multi-part log report:

  1. Issues NOTE: Invalid data for [variable_name] in line [L] column [C-C].
  2. Assigns a missing value (.) to the target variable.
  3. Sets the automatic binary error variable _ERROR_ = 1.
  4. Dumps the raw input buffer line with a column ruler (----+----1----+----2).
  5. Dumps the current contents of the Program Data Vector (PDV).
/* Example of Log Output during Invalid Raw Data ingestion */
RULE:     ----+----1----+----2----+----3----+----4
1         101 John_Doe  N/A   45000
NOTE: Invalid data for salary in line 1 18-20.
ID=101 Name=John_Doe salary=. _ERROR_=1 _N_=1
/* Common Diagnostic Messages Summary Table */
/* 
  Message: "NOTE: Missing values were generated as a result of performing an operation on missing values."
  Cause: An arithmetic calculation attempted to operate on a variable containing a missing value (.) using standard operators (+, -, *, /).
  
  Message: "NOTE: Variable [name] is uninitialized."
  Cause: A variable name was referenced on the right side of an assignment or in a statement without prior definition or reading.
  
  Message: "WARNING: The variable [name] on the DROP/KEEP list does not exist."
  Cause: A KEEP or DROP dataset option referenced a variable not present in the PDV.
*/

4. Controlling Log Output with System Options

In enterprise SAS pipelines, developers often control the level of detail written to the SAS log using system options or global statements.

A. System Options for Log Control

  • OPTIONS NOTES | NONOTES: Controls whether informational notes are printed to the SAS log. NONOTES suppresses notes (useful in production scripts to conserve log space), but does not suppress WARNING: or ERROR: messages.
  • OPTIONS SOURCE | NOSOURCE: Controls whether SAS source code statements are printed to the log.
  • OPTIONS MPRINT SYMBOLGEN: Enables detailed logging of SAS macro expansions and macro variable resolutions during execution.
/* Suppressing informational notes for clean log reporting */
options nonotes;
data work.clean_data;
    set work.raw_data;
run;
options notes; /* Always restore NOTES after processing */

B. Redirecting Log Output with PROC PRINTTO

By default, log messages are routed to the SAS Log window or standard output. PROC PRINTTO allows programmers to redirect the log to an external file:

/* Redirecting SAS Log to an external text file */
proc printto log='C:\SAS_Logs\daily_batch.log' new;
run;

/* All subsequent steps print log output to the external file */
data work.summary;
    set work.transactions;
run;

/* Restore default SAS Log destination */
proc printto;
run;

Exam Tip: Specifying NEW in PROC PRINTTO LOG= overwrites the existing file. Specifying ACCUM appends log output to the end of the existing file.

Test Your Knowledge

What sequence of actions does SAS perform when it encounters character text in an external file being read into a numeric variable via an INPUT statement?

A
B
C
D
Test Your Knowledge

A SAS programmer executes a production script with 'OPTIONS NONOTES;' enabled. Which of the following statements correctly describes the behavior of the SAS log?

A
B
C
D
Test Your Knowledge

Examine the following SAS log extract: NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column) 45:12 What caused SAS to write this specific note to the log?

A
B
C
D
Test Your Knowledge

Which PROC PRINTTO statement configuration correctly redirects the SAS log to an external file named 'audit.log', overwriting any existing contents in that file?

A
B
C
D