Friends, we saw how SAS finds errors for you. In today’s post we discuss how to read your SAS Log?
We all know that SAS log contains the coding statements that you submitted and messages from SAS explaining how it interpreted your coding statements. There are three types of messages you generally see in SAS Log window. These are all are important in evaluating your SAS code.
· Notes
· Warning messages
· Error messages
Let’s discuss individual SAS Log messages in detail.
Notes:
Notes communicate processing information. But it doesn’t identify coding mistakes.
Notes communicates about the data sets created and the number of variables and number of observations in each data set, the number of records read or written when processing external files, an indication that the step was stopped because of errors, an indication that a data value is invalid, an indication that an illegal mathematical operation was attempted, an indication that variable values were converted from character to numeric or from numeric to character and an indication that a statement in a DATA step generated a missing value.
Warning messages:
SAS Log indicates an action that SAS took when it encountered an error in your code. Most of the time SAS attempts to correct syntax errors that it identifies. If it can correct the error it display warning in the SAS log stating assumption that it made about your code. Don’t assume that when SAS makes the correction of your code, it has made the right correction. So always read warning messages to ensure that SAS displayed right message for you or not.
Error messages:
SAS writes an error message to the SAS log when it detects a syntax error or semantic error in your program that it cannot correct. You can easily find where in your program SAS suspects that an error occurred, because it underlines the code. A standard text message describes the error. This message is labeled with the keyword ERROR. In a windowing environment, the error message is usually displayed in a red color.
Now let’s talk about Debugging techniques in SAS. You can find errors specifying some SAS language components in Data steps.
SAS system options
FIRSTOBS= and OBS=
This option tells SAS to process the number of observations in the dataset. Select a subset of observations on which to test your program. Set to zero to check the syntax of the program and not process any observations.
REPLACE
This option allows replacement of permanent dataset. Don’t forget to mention the NOREPLACE option at end of the datasetp. Set to NOREPLACE when testing programs to protect data sets from being replaced.
LINESIZE
It specifies width of the SAS procedure output.
PAGESIZE
It specifies the no. of lines on a page of SAS procedure output.
PAGENO
It resets the page number to a specific value.
FMTERR
To stop the program when formats cannot be found.
NOFMTERR
When you have a permanent data set with variables that are associated to formats and you do not have access to the format library.
SOURCE
When testing programs so that you can locate the code associated with line numbers? SAS numbers the lines of your code and includes the line numbers in messages identifying problems with code or actions. It documents the processing of your program.
NOSOURCE
Set to NOSOURCE only after you have fully debugged your program.
Debugging SAS DATA Steps
ABORT
Stops executing the current DATA step, SAS job, or SAS session. Use when you want to stop processing a program immediately if a specific condition in your program exists.
ERROR
Sets the automatic variable _ERROR_ to 1 and optionally writes message to the SAS log. Use the ERROR statement when you want to make use of the _ERROR_ automatic variable. Use when you want your error message in the SAS log to be easy to find and descriptive?
LIST
Writes to the SAS log the input data line for the observation being processed. Use the LIST statement to display data lines where you think there may be data errors or data that may not be handled correctly by your INPUT statement.
PUT
Writes lines to the SAS log, when debugging programs, the PUT statement is typically used to write messages and variable values to the SAS log. Use the PUT statement to write variable values and messages to the SAS log or external file for conditions you want to examine. Use the PUT statement to write variable values and messages to the SAS log when SAS encounters specific errors in your program.
SKIP
Skips lines in the SAS log. Use SKIP to make your SAS log easier tor read.
STOP
Stops execution of the current DATA step. Use the STOP statement when you want to process a few observations in your DATA step or when you want processing to stop after SAS encounters a certain condition. Use the STOP statement when a condition encountered in your DATA step will cause problems if processing continues.
SAS Functions and Call Routines
SAS functions and call routines can help you correct errors in your SAS programs. With these features, you can find detailed information about your data values, external files, and variables.
Category
|
Functions and Routines
|
External files
|
FEXIST, FILEEXIST, FILEREF, FINFO
|
Macro
|
CALL EXECUTE, CALL SYMPUT
|
Other Special
|
GETOPTION, SYMGET
|
Character
|
INDEX, INDEXC, INDEXW
|
No comments:
Post a Comment
I love to hear from you! Leave a comment.
If your question is unrelated to this article, please use my Facebook page.