Debugging and Testing DATA Steps |
Debugging a DATA
Step |
Recognizing Errors in a DATA Step Program
This section teaches you how to debug common DATA step programming errors. After completing this section, you will be able to
You know how a DATA step is compiled and executed when written correctly. You probably also know that programs are rarely written correctly the first time. Error-checking features in SAS make it easy for you to debug your program as you develop it. When you submit your program, SAS evaluates it and, if errors are detected, writes messages to the SAS log. You can browse the messages, then correct and resubmit your program. SAS detects two types of errors:
|
data test <-- missing semicolon cet finance.records; <-- misspelled word if code=1 then Type='Variable"; <-- wrong quotation mark else Type='Fixed'; Interest=amount+rate; run; |
|
Description of Finance.Records
|
data test; set finance.records; if code=1 then Type='Variable'; <-- quotes missing else Type='Fixed'; Interest=amount+rate; run; |
In addition, any errors in your program logic
can sometimes cause a DATA step program to produce results that are different
from what you expect. For example, in this program, the value of
Interest should be calculated by multiplying Amount
by Rate , not by adding Amount to Rate . |
data test; set finance.records; if code='1' then Type='Variable'; else Type='Fixed'; Interest=amount+rate; <-- '+' should be '*' run; |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.