Setting Up and Executing Checkpoint Mode and Restart Mode
To set up checkpoint mode and restart mode, make the following modifications to your
batch program:
Add the CHECKPOINT EXECUTE_ALWAYS statement before any DATA and
PROC steps that you want to execute each time the batch program is submitted.
If your checkpoint-restart library is a user-defined library, you must add the
LIBNAME statement that defines the checkpoint-restart libref as the first statement
in the batch program. If you use the Work library as your checkpoint library, no
LIBNAME statement is necessary.
Once the batch program has been modified, you start the program using the appropriate
system options:
For checkpoint-restart data that is saved in the Work library, start a batch SAS
session that specifies these system options:
SYSIN, if required in your operating environment, names the batch program.
STEPCHKPT or LABELCHKPT enables checkpoint mode.
NOWORKTERM saves the Work library when SAS ends.
NOWORKINIT does not initialize the Work library when SAS starts.
ERRORCHECK STRICT puts SAS in syntax-check mode when an error occurs
in the LIBNAME, FILENAME, %INCLUDE, and LOCK statements.
ERRORABEND specifies whether SAS terminates for most errors.
CHKPTCLEAN specifies whether to erase files in the Work library and delete
the Work library if the batch program runs successfully.
In the Windows operating environment, the following SAS command starts a batch
program in checkpoint mode using the Work library as the checkpoint-restart library:
sas -sysin 'c:mysasmyprogram.sas'-stepchkpt -noworkterm -noworkinit
-errorcheck strict -errorabend -chkptclean
For checkpoint-restart data that is saved in a user-specified library, start a batch SAS
session that includes these system options:
SYSIN, if required in your operating environment, names the batch program.
STEPCHKPT or LABELCHKPT enables checkpoint mode.
STEPCHKPTLIB or LABELCHKPTLIB specifies the libref of the library where
SAS saves the checkpoint-restart data.
NOWORKTERM saves the Work library when SAS ends.
NOWORKINIT does not initialize the Work library when SAS starts.
ERRORCHECK STRICT puts SAS in syntax-check mode when an error occurs
in the LIBNAME, FILENAME, %INCLUDE, and LOCK statements.
ERRORABEND specifies whether SAS terminates for most errors.
In the Windows operating environment, the following SAS command starts a batch
program in checkpoint mode using a user-specified checkpoint-restart library:
sas -sysin 'c:mysasmyprogram.sas' -labelchkpt -labelchkptlib mylibref
-noworkterm -noworkinit -errorcheck strict -errorabbend
In this case, the first statement in MyProgram.sas is the LIBNAME statement that
defines the MyLibref libref.
150 Chapter 8 Error Processing and Debugging
Restarting Batch Programs
To resubmit a batch SAS session using the checkpoint-restart data that is saved in the
Work library, include these system options when SAS starts:
SYSIN, if required in your operating environment, names the batch program.
STEPCHKPT or LABELCHKPT continues checkpoint mode.
STEPRESTART or LABELRESTART enables restart mode, indicating to SAS to use
the checkpoint-restart data.
NOWORKINIT starts SAS using the Work library from the previous SAS session.
NOWORKTERM saves the Work library when SAS ends.
ERRORCHECK STRICT puts SAS in syntax-check mode when an error occurs in
the LIBNAME, FILENAME, %INCLUDE, and LOCK statements.
ERRORABEND specifies whether SAS terminates for most errors.
CHKPTCLEAN specifies whether to erase files in the Work library if the batch
program runs successfully.
In the Windows operating environment, the following SAS command resubmits a batch
program whose checkpoint-restart data was saved to the Work library:
sas -sysin 'c:mysasmysasprogram.sas' -stepchkpt -steprestart -noworkinit
-noworkterm -errorcheck strict -errorabend -chkptclean
By specifying the NOWORKTERM system options and either the STEPCHKPT or
LABELCHKPT system option, checkpoint mode continues to be enabled once the batch
program restarts.
To resubmit a batch SAS session using the checkpoint-restart data that is saved in a user-
specified library, include these system options when SAS starts:
SYSIN, if required in you operating environment, names the batch program.
STEPCHKPT or LABELCHKPT continues checkpoint mode.
STEPRESTART or LABELRESTART enables restart mode, indicating to SAS to use
the checkpoint-restart data.
STEPCHKPTLIB or LABELCHKPTLIB specifies the libref of the checkpoint-
restart library.
NOWORKTERM saves the Work library when SAS ends.
NOWORKINIT does not initialize the Work library when SAS starts.
ERRORCHECK STRICT puts SAS in syntax-check mode when an error occurs in
the LIBNAME, FILENAME, %INCLUDE, and LOCK statements.
ERRORABEND specifies whether SAS terminates for most errors.
In the Windows operating environment, the following SAS command resubmits a batch
program whose checkpoint-restart data was saved to a user-specified library:
sas -sysin 'c:mysasmysasprogram.sas' -labelchkpt -labelrestart -labelchklib
-noworkterm -noworkinit mylibref -errorcheck strict -errorabend
Using System Options to Control Error Handling
You can use the following system options to control error handling (resolve errors) in
your program:
Error Processing in SAS 151
BYERR
specifies whether SAS produces errors when the SORT procedure attempts to
process a _NULL_ data set.
CHKPTCLEAN
in checkpoint mode or reset mode, specifies whether to erase files in the Work
directory if a batch program executes successfully.
DKRICOND=
specifies the level of error detection to report when a variable is missing from an
input data set during the processing of a DROP=, KEEP=, and RENAME= data set
option.
DKROCOND=
specifies the level of error detection to report when a variable is missing from an
output data set during the processing of a DROP=, KEEP=, and RENAME= data set
option.
DSNFERR
when a SAS data set cannot be found, specifies whether SAS issues an error
message.
ERRORABEND
specifies whether SAS responds to errors by terminating.
ERRORCHECK=
specifies whether SAS enters syntax-check mode when errors are found in the
LIBNAME, FILENAME, %INCLUDE, and LOCK statements.
ERRORS=
specifies the maximum number of observations for which SAS issues complete error
messages.
FMTERR
when a variable format cannot be found, specifies whether SAS generates an error or
continues processing.
INVALIDDATA=
specifies the value that SAS assigns to a variable when invalid numeric data is
encountered.
LABELCHKPT
specifies whether SAS checkpoint-restart data is to be recorded for a batch program
that contains labeled code sections.
LABELCHKPTLIB
specifies the libref of the library where checkpoint-restart data is saved for labeled
code sections.
LABELRESTART
specifies whether to execute a batch program by using checkpoint-restart data for
labeled code sections.
MERROR
specifies whether SAS issues a warning message when a macro-like name does not
match a macro keyword.
QUOTELENMAX
if a quoted string exceeds the maximum length allowed, specifies whether SAS
writes a warning message to the SAS log.
152 Chapter 8 Error Processing and Debugging
SERROR
specifies whether SAS issues a warning message when a macro variable reference
does not match a macro variable.
STEPCHKPT
specifies whether checkpoint-restart data is to be recorded for a batch program.
STEPCHKPTLIB=
specifies the libref of the library where checkpoint-restart data is saved.
STEPRESTART
specifies whether to execute a batch program by using checkpoint-restart data.
VARINITCHK=
specifies whether to stop or continue processing a DATA step when a variable is not
initialized. You can also specify the type of message that is written to the SAS log.
VNFERR
specifies whether SAS issues an error or warning when a BY variable exists in one
data set but not another data set. SAS only issues these errors or warnings when
processing the SET, MERGE, UPDATE, or MODIFY statements.
For more information about SAS system options, see SAS System Options: Reference.
Using Return Codes
In some operating environments, SAS passes a return code to the system, but the way in
which return codes are accessed is specific to your operating environment.
Operating Environment Information
For more information about return codes, see the SAS documentation for your
operating environment.
Other Error-Checking Options
To help determine your programming errors, you can use the following methods:
the _IORC_ automatic variable that SAS creates (and the associated IORCMSG
function) when you use the MODIFY statement or the KEY= data set option in the
SET statement
the ERRORS= system option to limit the number of identical errors that SAS writes
to the log
the SYSRC and SYSMSG functions to return information when a data set or
external-files access function encounters an error condition
the SYSRC automatic macro variable to receive return codes
the SYSERR automatic macro variable to detect major system errors, such as out of
memory or failure of the component system
log control options:
MSGLEVEL=
controls the level of detail in messages that are written to the SAS log.
PRINTMSGLIST
controls the printing of extended lists of messages to the SAS log.
SOURCE
controls whether SAS writes source statements to the SAS log.
Error Processing in SAS 153
..................Content has been hidden....................

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