Using SAS/IML Software to Generate IML Statements |
The PUSH, QUEUE, and EXECUTE commands are especially useful when used in conjunction with the pause and resume features because they enable you to generate a pause-interrupt command to execute the code you push and return from it via a pushed RESUME statement. In fact, this is precisely how the EXECUTE subroutine is implemented generally.
CAUTION: Note that the push and resume features work this way only in the context of being inside modules. You cannot resume an interrupted sequence of statements in immediate mode - that is, not inside a module.
For example, suppose that you collect program statements in a matrix called CODE. You push the code to the command input stream along with a RESUME statement and then execute a PAUSE statement. The PAUSE statement interrupts the execution, parses and executes the pushed code, and returns to the original execution via the RESUME statement. Here is the code:
proc iml; start testpush; print '*** ENTERING MODULE TESTPUSH ***'; print '*** I should be 1,2,3: '; /* constructed code * / code = ' do i = 1 to 3; print i; end; '; /* push code+resume */ call push (code, 'resume;'); /* pause interrupt */ pause; print '*** EXITING MODULE TESTPUSH ***'; finish;When the PAUSE statement interrupts the program, the IML procedure then parses and executes the following line:
do i=1 to 3; print i; end; resume;The RESUME command then causes the IML procedure to resume the module that issued the PAUSE.
Note: The EXECUTE routine is equivalent to a PUSH command, but it also adds the push of a RESUME command, then issues a pause automatically.
A CALL EXECUTE command should be used only from inside a module because pause and resume features do not support returning to a sequence of statements in immediate mode.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.