input x ? 10-12;
_error_=0;
In either case, SAS sets the invalid values of X to missing values.
Macro-related Errors
Several types of macro-related errors exist:
macro compile time and macro execution-time errors, generated when you use the
macro facility itself
errors in the SAS code produced by the macro facility
For more information about macros, see SAS Macro Language: Reference.
Error Processing in SAS
Syntax Check Mode
Overview of Syntax Check Mode
If you want processing to stop when a statement in a DATA step has a syntax error, you
can enable SAS to enter syntax check mode. You do this by setting the
SYNTAXCHECK system option in batch or non-interactive mode, or by setting the
DMSSYNCHK system option in the windowing environment.
SAS can enter syntax check mode only if your program creates a data set. If you use the
DATA _NULL_ statement, then SAS cannot enter syntax check mode because no data
set is created. In this case, using the SYNTAXCHECK or DMSSYNCHK system option
has no effect.
In syntax check mode, SAS internally sets the OBS= option to 0 and the REPLACE/
NOREPLACE option to NOREPLACE. When these options are in effect, SAS acts as
follows:
reads the remaining statements in the DATA step or PROC step
checks that statements are valid SAS statements
executes global statements
writes errors to the SAS log
creates the descriptor portion of any output data sets that are specified in program
statements
does not write any observations to new data sets that SAS creates
does not execute most of the subsequent DATA steps or procedures in the program
(exceptions include PROC DATASETS and PROC CONTENTS)
Note: Any data sets that are created after SAS has entered syntax check mode do not
replace existing data sets with the same name.
When syntax checking is enabled, SAS underlines the point where it detects a syntax or
semantic error in a DATA step and identifies the error by number. SAS then enters
syntax check mode and remains in this mode until the program finishes executing. When
SAS enters syntax check mode, all DATA step statements and PROC step statements are
validated.
Error Processing in SAS 145
Enabling Syntax Check Mode
You use the SYNTAXCHECK system option to enable syntax check mode when you run
SAS in non-interactive or batch mode. You use the DMSSYNCHK system option to
enable syntax check mode when you run SAS in the windowing environment. You can
use these system options only if your program creates a data set. If you use the DATA
_NULL_ statement, then these options are ignored.
To disable syntax check mode, use the NOSYNTAXCHECK and NODMSSYNCHK
system options.
In an OPTIONS statement, place the OPTIONS statement that enables
SYNTAXCHECK or DMSSYNCHK before the step for which you want it to apply. If
you place the OPTIONS statement inside a step, then SYNTAXCHECK or
DMSSYNCHK does not take effect until the beginning of the next step.
For more information about these system options, see “DMSSYNCHK System Option”
in SAS System Options: Reference and “SYNTAXCHECK System Option” in SAS
System Options: Reference.
Processing Multiple Errors
Depending on the type and severity of the error, the method that you use to run SAS, and
your operating environment, SAS either stops program processing or flags errors and
continues processing. SAS continues to check individual statements in procedures after
it finds certain types of errors. In some cases SAS can detect multiple errors in a single
statement and might issue more error messages for a given situation. This is likely to
occur if the statement containing the error creates an output SAS data set.
The following example illustrates a statement with two errors:
data temporary;
Item1=4;
run;
proc print data=temporary;
var Item1 Item2 Item3;
run;
146 Chapter 8 Error Processing and Debugging
Log 8.8 SAS Log: Multiple Program Errors
273 data temporary;
274 Item1=4;
275 run;
NOTE: The data set WORK.TEMPORARY has 1 observations and 1
variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
276
277 proc print data=temporary;
ERROR: Variable ITEM2 not found.
ERROR: Variable ITEM3 not found.
278 var Item1 Item2 Item3;
279 run;
NOTE: The SAS System stopped processing this step because of
errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.52 seconds
cpu time 0.00 seconds
280 proc printto; run;
SAS displays two error messages, one for the variable Item2 and one for the variable
Item3.
When you are running debugged production programs that are unlikely to encounter
errors, you might want to force SAS to abend after a single error occurs. You can use the
ERRORABEND system option to do this.
Checkpoint Mode and Restart Mode
Overview of Checkpoint Mode and Restart Mode
When used together, checkpoint mode and restart mode create an environment where
batch programs that terminate before completing can be resubmitted without rerunning
steps or labeled code sections that have already completed. Execution resumes with
either the DATA or PROC step or the labeled code section that was executing when the
failure occurred.
A labeled code section is the SAS code that begins with label: outside of a DATA or
PROC step and ends with the RUN statement that precedes the next label: that is outside
of a DATA or PROC step,. Labels must be unique. Consider using labeled code sections
when you want to group DATA or PROC steps that might need to be grouped together
because the data for one is dependent on the other.
The following example program has two labeled code sections. The first labeled code
section begins with the label readSortData: and ends with the run; statement for
proc sort data=mylib.mydata;. The second labeled code section starts with the
label report: and ends with the run; statements for proc report
data=mylib.mydata;
.
readSortData:
data mylib.mydata;
...more sas code...
run;
proc sort data=mylib.mydata;
Error Processing in SAS 147
...more sas code...
run;
report:
proc report data=mylib.mydata;
...more sas code...;
run;
endReadSortReport:
Note: The use of label: in checkpoint mode and restart mode is valid only outside of a
DATA or PROC statement. Checkpoint mode and restart mode for labeled code
sections are not valid for labels within a DATA step or macros.
Checkpoint mode and restart mode can be enabled for either DATA and PROC steps or
for labeled code sections, but not both simultaneously. To use checkpoint mode and
restart mode on a step-by-step basis, use the step checkpoint mode and the step restart
mode. To use checkpoint mode and restart mode based on groups of code sections, use
the label checkpoint mode and the label restart mode. Each group of code is identified by
a unique label. If you use labels, all steps in a SAS program must belong to a labeled
code section.
When checkpoint mode is enabled, SAS records information about DATA and PROC
steps or labeled code sections in a checkpoint library. When a batch program terminates
prematurely, you can resubmit the program in restart mode to complete execution. In
restart mode, global statements are re-executed, macro definitions are recompiled, and
macros are re-executed.. SAS reads the data in the checkpoint library to determine which
steps or labeled code sections completed. Program execution resumes with the step or
the label that was executing when the failure occurred.
The checkpoint-restart data contains information only about the DATA and PROC steps
or the labeled code sections that completed and the step or labeled code sections that did
not complete. The checkpoint-restart data does not contain the following information:
information about macro variables and macro definitions
information about SAS data sets
information that might have been processed in the step or labeled code section that
did not complete
Note: Checkpoint mode is not valid for batch programs that contain the DM statement
to submit commands to SAS. If checkpoint mode is enabled and SAS encounters a
DM statement, checkpoint mode is disabled and the checkpoint catalog entry is
deleted.
As a best practice, if you use labeled code sections, add a label at the end of your
program. When the program completes successfully, the label is recorded in the
checkpoint-restart data. If the program is submitted again in restart mode, SAS knows
that the program has already completed successfully.
If a DATA or PROC step must be re-executed, you can add the global statement
CHECKPOINT EXECUTE_ALWAYS immediately before the step. This statement tells
SAS to always execute the following step without considering the checkpoint-restart
data. It is applicable only to the step that follows the statement. For more information,
see “CHECKPOINT EXECUTE_ALWAYS Statement” in SAS Statements: Reference.
You enable checkpoint mode and restart mode for DATA and PROC steps by using
system options when you start the batch program in SAS.
STEPCHKPT system option enables checkpoint mode, which indicates to SAS to
record checkpoint-restart data
148 Chapter 8 Error Processing and Debugging
STEPCHKPTLIB system option identifies a user-specified checkpoint-restart library
STEPRESTART system option enables restart mode, ensuring that execution
resumes with the DATA or PROC step indicated by the checkpoint-restart library.
You enable checkpoint mode and the restart mode for labeled code sections by using
these system options when you start the batch program in SAS:
LABELCHKPT system option enables checkpoint mode for labeled code sections,
which indicates to SAS to record checkpoint-restart data.
LABELCHKPTLIB system option identifies a user-specified checkpoint-restart
library
LABELRESTART system option enables restart mode, ensuring that execution
resumes with the labeled code section indicated by the checkpoint-restart library.
If you use the Work library as your checkpoint-restart library, you can use the
CHKPTCLEAN system option to have the files in the Work library erased after a
successful execution of your batch program.
For information, see the following system options in SAS System Options: Reference:
“STEPCHKPT System Option” in SAS System Options: Reference
“STEPCHKPTLIB= System Option” in SAS System Options: Reference
“STEPRESTART System Option” in SAS System Options: Reference
“LABELCHKPT System Option” in SAS System Options: Reference
“LABELCHKPTLIB= System Option” in SAS System Options: Reference
“LABELRESTART System Option” in SAS System Options: Reference
“CHKPTCLEAN System Option” in SAS System Options: Reference
Requirements for Using Checkpoint Mode and Restart Mode
In order for checkpoint mode and restart mode to work successfully, the number and
order of the DATA and PROC steps or labeled code sections in the batch program must
not change between SAS invocations. By specifying the ERRORABEND and
ERRORCHECK system options when SAS starts, SAS terminates for most error
conditions in order to maintain valid checkpoint-restart data.
The checkpoint-restart library can be a user-specified library or, if no library is specified,
the checkpoint-restart data is saved to the Work library. Always start SAS with the
NOWORKTERM and NOWORKINIT system options regardless of whether the
checkpoint-restart data is saved to a user-specified library or to the Work library. SAS
writes the name of the Work library to the SAS log.
Operating Environment Information
Under UNIX and z/OS operating environments, consider always assigning a
checkpoint-restart library when you use the STEPCHKPT option or the
LABELCHKPT option. If your site sets the CLEANWORK utility to run at regular
intervals, data in the Work library might be lost. Under z/OS, it might not be
practical for your site to reuse the Work library in a batch session.
The labels for labeled code sections must be unique. If SAS enters restart mode for a
label that is a duplicate label, SAS starts at the first label. The code between the
duplicate labels might rerun needlessly.
Error Processing in SAS 149
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.50.87