The general form of the PAUSE statement is as follows:
PAUSE
<message> <*> ;
The PAUSE statement does the following:
stops execution of a module
remembers where it stopped
prints a message that you can specify
sets the current program environment and symbol table to be that of the module that contains the PAUSE statement. This means that you can type statements that reference local variables in the module. For example, you might want to use a PAUSE statement while debugging a module so that you can print the value of local variables.
A RESUME statement enables you to continue execution at the location of the most recent PAUSE statement.
You can use a STOP statement as an alternative to the RESUME statement to remove the paused state and to return to the main scope outside the module. You can specify a message in the PAUSE statement. This message is displayed in the output window when the PAUSE statement is executed. For example, the following PAUSE statements each display a message:
pause "Please enter an assignment for X, then enter RESUME;"; msg = "Please enter an assignment for X, then enter RESUME;"; pause msg;
The PAUSE statement also writes a note to the SAS log. To suppress the note, use the * option, as shown in the following statement:
pause *;
When you use a PAUSE, RESUME, STOP, or ABORT statement, keep in mind the following details:
The PAUSE statement must be used from inside a module.
It is an error to execute a RESUME statement without any outstanding pauses.
You can define and execute modules while paused within another module.
If a run-time error occurs inside a module, a PAUSE statement is automatically executed. This gives you an opportunity to correct the error and resume execution of the module with a RESUME statement. Alternately, you can submit a STOP statement to exit from the module environment, or an ABORT statement to exit PROC IML.
You cannot reenter or redefine an active (paused) module.
When paused, you can run another module that also pauses. The paused environments are stacked.
You can put a RESUME statement inside a module. For example, suppose you are paused in module A and then run module B, which executes a RESUME statement. Execution is resumed in module A and does not return to module B.
You can use the PAUSE and RESUME statements in both subroutine and function modules.
If you pause in a subroutine module that has its own symbol table, then the statements executed while paused use this symbol table. You must use a RESUME or a STOP statement to return to the global symbol table environment.
You can use the PAUSE and RESUME statements, in conjunction with the PUSH, QUEUE, and EXECUTE subroutines described in Chapter 19: Using SAS/IML Software to Generate SAS/IML Statements, to execute SAS/IML statements that you generate within a module.