Chapter 5: Identifying and Correcting SAS Language Errors
Correct answer: a
To correct errors in
programs when you use the Editor window, you usually need to recall
the submitted statements from the recall buffer to the Editor window.
After correcting the errors, you can resubmit the revised program.
However, before doing so, it is a good idea to clear the messages
from the SAS log so that you do not confuse the old error messages
with the new messages. Remember to check the SAS log again to verify
that your program ran correctly.
Correct answer: d
The missing quotation
mark in the LABEL statement causes SAS to misinterpret the statements
in the program. When you submit the program, SAS is unable to resolve
the PROC step, and a PROC PRINT running message
appears at the top of the active window.
Correct answer: c
Syntax errors generally
cause SAS to stop processing the step in which the error occurred.
When a program that contains an error is submitted, messages regarding
the problem also appear in the SAS log. When a syntax error is detected,
the SAS log displays the word ERROR, identifies the possible location
of the error, and gives an explanation of the error.
Correct answer: c
Syntax errors occur
because the program statements did not conform to the rules of the
SAS language. Syntax errors, such as misspelled keywords, generally
prevent SAS from executing the step in which the error occurred.
Correct answer: b
When you submit a SAS
statement that contains an invalid option, a log message notifies
you that the option is not valid or not recognized. You should recall
the program, remove or replace the invalid option, check your statement
syntax as needed, and resubmit the corrected program.
Correct answer: b
The DATA step contains
a misspelled keyword (dat instead of data). However, this is such
a common (and easily interpretable) error that SAS produces only a
warning message, not an error.
Correct answer: d
The _N_ and _ERROR_
temporary variables can be helpful when debugging a DATA step. The
_N_ variable displays debugging messages for a specified number of
iterations of the DATA step. The _ERROR_ displays debugging messages
when an error occurs.
Correct answer: d
You can use the PUTLOG
statement or the PUT statement to help identify errors and print messages
in the SAS log. You can use the PUTLOG statement in a DATA step to
write messages to the SAS log to help identify logic errors. You can
also use temporary variables in the PUTLOG to assist in debugging.
You can use the PUT statement to examine variables and print your
own message to the SAS log.
Correct answer: c
A logic error occurs
when the program statements follow the rules and execute, but the
results are not correct. You can use the PUTLOG statement in the DATA
step to help identify logic errors.