Defining and Executing a Module |
A module definition begins with a START statement, which has the following general form:
A module definition ends with a FINISH statement, which has the following general form:
If no name appears in the START statement, the name of the module defaults to MAIN. If no name appears on the FINISH statement, the name of the most recently defined module is used.
There are two ways you can execute a module: you can use either a RUN statement or a CALL statement. The general forms of these statements are as follows:
The only difference between the RUN and CALL statements is the order of resolution. The RUN statement is resolved in the following order:
user-defined module
SAS/IML built-in subroutine
In contrast, the CALL statement is resolved in the opposite order:
SAS/IML built-in subroutine
user-defined module
In other words, if you define a module with the same name as a SAS/IML subroutine, you can use the RUN statement to call the user-defined module and the CALL statement to call the built-in subroutine.
The RUN and CALL statements must have arguments that correspond to the ones defined in the START statement. A module can call other modules provided that it never recursively calls itself.
After the last statement in a module is executed, control returns to the statement that initially called the module. You can also force a return from a module by using the RETURN statement.