The WAITFOR statement
suspends execution of the current SAS session until the specified
task(s) finish executing or until the TIMEOUT interval (if specified)
has elapsed. If the specified task was started with the XWAIT option,
then the WAITFOR statement ignores that task.
For example, the following
statements start three different SAS jobs and suspend the execution
of the current SAS session until those three jobs have finished executing:
systask command "sas myprog1.sas" taskname=sas1;
systask command "sas myprog2.sas" taskname=sas2;
systask command "sas myprog3.sas" taskname=sas3;
waitfor _all_ sas1 sas2 sas3;
The SYSRC macro variable
contains the return code for the WAITFOR statement. If a WAITFOR statement
cannot execute successfully, the SYSRC macro variable will contain
a nonzero value. For example, the WAITFOR statement can contain syntax
errors. If the number of seconds specified with the TIMEOUT option
elapses, then the WAITFOR statement finishes executing, and SYSRC
is set to a nonzero value if
-
you specify a single task that
does not finish executing
-
you specify more than one task
and the _ANY_ option (which is the default setting), but none of the
tasks finishes executing
-
you specify more than one task
and the _ALL_ option, and any one of the tasks does not finish executing.
Any task whose status variable is still NULL after
the WAITFOR statement has executed did not complete execution.