Using SAS/IML Software to Generate SAS/IML Statements |
Executing Any Command in an EXECUTE Call |
The EXECUTE command executes the statements contained in the arguments by using the same facilities as a sequence of CALL PUSH, PAUSE, and RESUME statements. The statements use the same symbol environment as that of the subroutine that calls them. For example, consider the following subroutine:
proc iml; start exectest; /* IML STATEMENTS */ call execute ("xnum = {1 2 3, 4 5 6, 7 8 0};"); call execute ("create dsnum1 from xnum;"); call execute ("append from xnum;"); call execute ("print 'DSNUM should have 3 obs and 3 var:';"); call execute ("list all;"); /* global (options) statement */ call execute ("options linesize=68;"); call execute ("print 'Linesize should be 68';"); finish; run exectest;
The following output generated from EXECTEST is exactly the same as if you had entered the statements one at a time:
DSNUM should have 3 obs and 3 var: OBS COL1 COL2 COL3 ------ --------- --------- --------- 1 1.0000 2.0000 3.0000 2 4.0000 5.0000 6.0000 3 7.0000 8.0000 0 Linesize should be 68
CALL EXECUTE could almost be programmed in IML as shown here; the difference between this and the built-in command is that the following subroutine would not necessarily have access to the same symbols as the calling environment:
start execute(command1,...); call push(command1,...," resume;"); pause; finish;
Copyright © SAS Institute, Inc. All Rights Reserved.