Previous Page | Next Page

Statements under z/OS

WAITFOR Statement: z/OS

Suspends execution of the current SAS session until the specified tasks finish executing.
Valid: anywhere
z/OS specifics: all

See Also


WAITFOR <_ANY_ | _ALL_> taskname1 <taskname2 ...tasknameX> <TIMEOUT=seconds>;


specifies the name of the remotely submitted tasks that you want to complete execution before resuming execution of SAS. You cannot use wildcards to specify task names. Resumption of the SAS session depends first on the value of the TIMEOUT= option and second on the execution state of the specified tasks.

_ANY_ | _ALL_

suspends execution of the current SAS session until either one or all of the specified remote tasks finishes execution. The default setting is _ANY_, which means that as soon as one of the specified tasks completes execution, the WAITFOR statement also finishes execution. Note again that resumption of execution is primarily dependent on the TIMEOUT= option.


specifies the maximum number of seconds that WAITFOR should suspend the current SAS session, regardless of the execution state of any or all specified tasks. The SAS session resumes execution at the end of the TIMEOUT= period even if specified tasks are still executing. If you do not specify the TIMEOUT= option and you do not specify any task names, WAITFOR suspends execution of the SAS session indefinitely. If you specify any task names and you do not specify a TIMEOUT= value, the SAS session resumes execution when the specified tasks complete execution. Specifying TIMEOUT= without specifying task names suspends SAS execution for the specified number of seconds.


Task names can be listed with the SYSTASK LIST statement. These task names are assigned on other hosts and are supplied to the z/OS SAS session via RSUBMIT commands or statements in SAS/CONNECT software.

The SYSRC macro variable contains the return code for the WAITFOR statement. If a WAITFOR statement cannot execute successfully, then the SYSRC macro variable is set to a nonzero value. For example, the WAITFOR statement might contain syntax errors. If the number of seconds specified with the TIMEOUT option elapses, then the WAITFOR statement finishes executing and the SYSRC macro variable is set to a nonzero value if any of the following occur:

See Also

Previous Page | Next Page | Top of Page