The EXECUTE subroutine immediately executes SAS statements. These can be SAS/IML statements or global SAS statements such as the TITLE statement. The arguments to the EXECUTE subroutine are character matrices or quoted literals that contains valid SAS statements. You can specify up to 15 arguments.
The EXECUTE subroutine pushes character arguments to the input command stream, executes them, and then returns to the calling module. The subroutine should be called from a module rather than from the immediate environment because it uses the RESUME statement that works only from modules). The strings you push do not appear in the log.
Following are examples of valid EXECUTE subroutines:
/* define a module that writes data to a specified data set */ start WriteData(DSName, x); CreateStmt = "create " + DSName + " from x;"; /* build CREATE stmt */ call execute(CreateStmt); /* run CREATE stmt */ append from x; CloseStmt = "close " + DSName + ";"; /* build CLOSE stmt */ call execute(CloseStmt); /* run CLOSE stmt */ finish; y = {1 2 3, 4 5 6, 7 8 0}; run WriteData("MyData", y); /* call the module */ use MyData; list all; close MyData; /* verify contents */
Figure 24.122: Results of Executing SAS/IML Statements
OBS COL1 COL2 COL3 ------ --------- --------- --------- 1 1.0000 2.0000 3.0000 2 4.0000 5.0000 6.0000 3 7.0000 8.0000 0 |
For more details about the EXECUTE subroutine, see Chapter 19: Using SAS/IML Software to Generate SAS/IML Statements.