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 Log window when the program finishes executing. When a program that contains an error is submitted, messages about the error appear in the Log window. 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

In the program below, the DATA step copies the SAS data set Clinic.Admit into a new data set named Clinic.Admitfee. The PROC step should print the values for the variables ID, Name, Actlevel, and Fee in the new data set. However, the SAS keyword print is misspelled in the PROC PRINT statement.
data sasuser.admitfee; 
   set sasuser.admit; 
run; 
proc prin data=sasuser.admitfee; 
   var id name actlevel fee; 
run;
When the program is submitted, messages in the Log window 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.
Figure 4.1 Log Window Displaying Error Message
Log Window Displaying Error Message
Note: Errors in your statements or data might not be evident when you look at results in the Results viewer. Review the messages in the Log window 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: January 10, 2018
..................Content has been hidden....................

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