0% found this document useful (0 votes)
4 views14 pages

Editing & Debugging Sas Programs 1

The document discusses the importance of debugging in SAS programming, outlining the steps SAS takes when a program is submitted, including compiling for syntax errors, executing the program, and analyzing data. It identifies four types of errors: syntax, semantic, execution-time, and data errors, providing examples and explanations for each. The document emphasizes the need for programmers to check the SAS Log for error messages and to possess statistical knowledge to resolve issues effectively.

Uploaded by

roopeshkavali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

Editing & Debugging Sas Programs 1

The document discusses the importance of debugging in SAS programming, outlining the steps SAS takes when a program is submitted, including compiling for syntax errors, executing the program, and analyzing data. It identifies four types of errors: syntax, semantic, execution-time, and data errors, providing examples and explanations for each. The document emphasizes the need for programmers to check the SAS Log for error messages and to possess statistical knowledge to resolve issues effectively.

Uploaded by

roopeshkavali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

EDITING &

DEBUGGING SAS
PROGRAMS
IMPORTANCE OF DEBUGGING IN SAS PROGRAM

 Being a good SAS programmer requires being a good SAS debugger.


SAS Debugging involves first the identification of errors or issues
and then methods to resolve the issue
WHAT DOES SAS SYSTEM DO
WHEN WE SUBMIT A PROGRAM?
When we submit a SAS program, SAS performs the following tasks.
(1) Compile the program to check for syntax errors.
(2) If there is no syntax errors, execute the program to read, process, manipulate
the data.
(3) Analyze the data and generate the resulting reports.
At the step (1), results of compiling the program are displayed in the SAS Log
window. The programmer checks the SAS Log to correct the program and
resubmit it until no syntax error.
At Step (2), read, process and manipulate the data. If the program logic is not
correct, the results will not be correct. Some errors may be displayed in the
SAS Log, but some errors may not be displayed. These errors are not due to
syntax or due to data, but, due to the program logic is not correct to
accomplish the purpose. may not be displayed as all.
At Step (3), data are analyzed. Errors occur often due to wrong statistical analysis.
This requires proper statistical knowledge to correct the errors
IDENTIFYING ERRORS AND RESOLVING PROBLEMS:-

 In general, SAS uses color-coding system to display right (BLUE) and wrong

(RED) errors in SAS log.

 After submitting the program, go to SAS Log to check if there are ‘red’ error
messages.
ERROR MESSAGES IN SAS LOG

 SAS recognizes four types of errors.

I. Syntax error
II. Smatic error
III. Execution time error
IV. Data error.
SYNTAX ERROR : -
 Syntax errors occur when program statements do not conform to the rules
of the SAS language. Here are some examples of syntax errors:
• misspelled SAS keyword
• unmatched quotation marks
• missing a semicolon
• invalid statement option
• invalid data set option.
SEMANTIC ERRORS : -
 Semantic errors occur when the form of the elements in a SAS statement is correct,
but the elements are not valid for that usage. Semantic errors are detected at compile
time and can cause SAS to enter syntax check mode.
 Examples of semantic errors include the following:

• specifying the wrong number of arguments for a function


• using a numeric variable name where only a character variable is valid
• using illegal references to an array.
EXECUTION-TIME ERRORS : -

Execution-time errors are errors that occur when SAS executes a program that
processes data values. Most execution-time errors produce warning messages or notes in
the SAS log but allow the program to continue executing.
 Common execution-time errors include the following:

• illegal arguments to functions


• illegal mathematical operations (for example, division by 0)
• observations in the wrong order for BY-group processing
• reference to a nonexistent member of an array (occurs when the array's subscript is out of
range)
• open and close errors on SAS data sets and other files in INFILE and FILE statements
• INPUT statements that do not match the data lines (for example, an INPUT statement in
which you list the wrong columns for a variable or fail to indicate that the variable is a
character variable).
DATA ERRORS : -
 Data errors occur when some data values are not appropriate for the SAS
statements that you have specified in the program. For example, if you define a
variable as numeric, but the data value is actually character, SAS generates a data
error. SAS detects data errors during program execution and continues to execute the
program, and does the following:
• writes an invalid data note to the SAS log.
• prints the input line and column numbers that contain the invalid value in the SAS log.
Unprintable characters appear in hexadecimal. To help determine column numbers,
SAS prints a rule line above the input line.
• prints the observation under the rule line.
• sets the automatic variable _ERROR_ to 1 for the current observation.
THANK YOU

You might also like