CALL EXECUTE (statements);
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 25.122: Results of Executing SAS/IML Statements
For more details about the EXECUTE subroutine, see ChapterĀ 20: Using SAS/IML Software to Generate SAS/IML Statements.