SLEEP Function: Windows

Suspends execution of a SAS DATA step for a specified period of time.

Category: Special
Windows specifics: all
See: SLEEP Function in SAS Functions and CALL Routines: Reference

Syntax

SLEEP(n<,unit>)

Required Argument

n

specifies the number of seconds that you want to suspend execution of a DATA step. The n argument is a numeric constant that must be greater than or equal to 0. Negative or missing values for n are invalid.

Optional Argument

unit

specifies the unit of seconds, as a multiple of 10, which is applied to n. For example, 1 corresponds to a second, and .001 to a millisecond. The default value is 1.

Details

The SLEEP function suspends execution of a DATA step for a specified number of seconds. When the SLEEP function uses the default unit value, a pop-up window appears that indicates how long SAS is going to sleep.
The return value of the n argument is the number of seconds slept. The maximum sleep period for the SLEEP function is 46 days.
When you submit a program that calls the SLEEP function, the SLEEP window appears, telling you when SAS is going to wake up. You can inhibit the SLEEP window by starting SAS with the NOSLEEPWINDOW system option. Your SAS session remains inactive until the sleep period is over. To cancel the call to the SLEEP function, use the CTRL+BREAK attention sequence.
You should use a null DATA step to call the SLEEP function; follow this DATA step with the rest of the SAS program. Using theSLEEP function in this manner enables you to use the CTRL+BREAK attention sequence to interrupt the SLEEP function and to continue with the execution of the rest of your SAS program.

Example

The following example tells SAS to delay the execution of the program for 12 hours and 15 minutes:
data _null_;
   /* argument to sleep must be expressed in seconds */
   slept= sleep((60*60*12)+(60*15));
run;
data monthly;
   /*... more data lines */
run;