SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Debugging and Testing DATA Steps
Debugging a DATA Step


Diagnosing Syntax Errors

The DATA step shown below has a common syntax error: the semicolon is missing from the end of a statement. Without the semicolon, SAS cannot determine the end of the statement.

     data annual;        V
        set finance.loans
        Interest=amount*rate;
     run;

As a result, during compilation, the assignment statement is misread as part of the SET statement. The equal sign is detected as invalid in a SET statement, and an ERROR message is written to the SAS log.


The SAS Log window displays error messages.

When the DATA step compiles, the SAS data set Work.Annual is created. However, due to the syntax error, the DATA step does not execute. The new data set contains no observations or variables. The error, or the point at which the error is detected, is underlined. Errors are also labeled with a number so you can identify each error if there is more than one.

A note in the log indicates the action taken. A DATA step with syntax errors is compiled but may not execute. In addition, a warning indicates that there are zero observations and zero variables in the new data set. You can determine the error by reviewing your program. Begin at the detected error and read backwards to the top of the DATA step to locate the source of the error.

In this case, you should notice the missing semicolon in the SET statement. You can correct the DATA step by adding the missing semicolon to the SET statement and resubmitting the program.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement