WAKEUP Function: Windows

Specifies the time a SAS DATA step continues execution.
Category: Special
Windows specifics: all

Syntax

WAKEUP(until-when)

Required Argument

until-when
specifies the time when the WAKEUP function allow execution to continue.

Details

Use the WAKEUP function to specify the time a DATA step continues to execute. The return value is the number of seconds slept.
The until-when argument can be a SAS datetime value, a SAS time value, or a numeric constant, as explained in the following list:
  • If until-when is a datetime value, the WAKEUP function sleeps until the specified date and time. If the specified date and time have already passed, the WAKEUP function does not sleep, and the return value is 0.
  • If until-when is a time value, the WAKEUP function sleeps until the specified time. If the specified time has already passed in that 24-hour period, the WAKEUP function sleeps until the specified time occurs again.
  • If the value of until-when is a numeric constant, the WAKEUP function sleeps for that many seconds before or after the next occurring midnight. If the value of until-when is a positive numeric constant, the WAKEUP function sleeps for until-when seconds past midnight. If the value of until-when is a negative numeric constant, the WAKEUP function sleeps until until-when seconds before midnight.
Negative values for the until-when argument are allowed, but missing values are not. The maximum sleep period for the WAKEUP function is approximately 46 days.
When you submit a program that calls the WAKEUP 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 waiting period is over. If you want to cancel the call to the WAKEUP function, use the CTRL + BREAK attention sequence.
You should use a null DATA step to call the WAKEUP function; follow this DATA step with the rest of the SAS program. Using the WAKEUP function in this manner enables you to use the CTRL+BREAK attention sequence to interrupt the waiting period and continue with the execution of the rest of your SAS program.

Examples

Example 1: Delaying Program Execution until a Specified Date or Time

The code in this example tells SAS to delay execution of the program until 1:00 p.m. on January 1, 2004:
data _null_;
   slept=wakeup('01JAN2004:13:00:00'dt);
run;
data compare;
   /* ...more data lines */
run;
The following example tells SAS to delay execution of the program until 10:00 p.m.:
data _null_;
   slept=wakeup("22:00:00"t);
run;
data compare;
   /* ...more data lines */
run;

Example 2: Delaying Program Execution until a Specified Time Period after Midnight

The following example tells SAS to delay execution of the program until 35 seconds after the next occurring midnight:
data _null_;
   slept=wakeup(35);
run;
data compare;
   /* ...more data lines */
run;

Example 3: Using a Variable as an Argument to the WAKEUP Function

This example illustrates using a variable as the argument of the WAKEUP function:
data _null_;
   input x;
   slept=wakeup(x);
   datalines;
1000
;
data compare;
   input article1 $ article2 $ rating;
   /* ...more data lines */
run;
Because the instream data indicate that the value of X is 1000, the WAKEUP function sleeps for 1,000 seconds past midnight.