Error Messages

Types of Errors

SAS can detect several types of errors. Here are two common ones:
  • syntax errors that occur when program statements do not conform to the rules of the SAS language
  • semantic errors that occur when you specify a language element that is not valid for a particular usage

Syntax Errors

When you submit a program, SAS scans each statement for syntax errors, and then executes the step (if no syntax errors are found). SAS then goes to the next step and repeats the process. Syntax errors, such as misspelled keywords, generally prevent SAS from executing the step in which the error occurred.
Notes are written to the SAS log when the program finishes executing. When a program that contains an error is submitted, messages about the error appear in the SAS log. Here is what SAS does:
  • displays the word ERROR
  • identifies the possible location of the error
  • gives an explanation of the error

Example: Syntax Error Messages

The following program contains a syntax error:
data work.admitfee;             /*#1*/
  set cert.admit;
run;
proc prin data=work.admitfee;   /*#2*/
  var id name actlevel fee;     /*#3*/
run;
1 The DATA step creates a new SAS data set named Work.Admitfee from the Cert.Admit data set.
2 The SAS keyword PRINT in PROC PRINT is spelled incorrectly. As a result, the PROC step fails.
3 The VAR statement prints the values for the following variables only: ID, Name, ActLevel, and Fee.
When the program is submitted, messages in the SAS log indicate that the procedure PRIN was not found and that SAS stopped processing the PROC step because of errors. No output is produced by the PRINT procedure, because the second step fails to execute.
Here is an explanation of the following log.
  • The ERROR keyword is the notification of the error.
  • The PRIN keyword in the SAS log is the possible location of the error in the statement.
  • The error explanation is not found.
Log 5.1 SAS Log
265  proc prin data=work.admitfee;
ERROR: Procedure PRIN not found.
268    var id name actlevel fee;
267  run;
NOTE: The SAS System stopped processing this step because of errors.
Tip
Errors in your statements or data might not be evident when you look at results in the Results viewer. Review the messages in the SAS log each time you submit a SAS program.
In addition to correcting spelling mistakes, you might need to resolve other common syntax errors such as these:
  • missing RUN statement
  • missing semicolon
  • unbalanced quotation mark
You might also need to correct a semantic error such as this:
  • invalid option
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.137.37