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;
...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
-
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.