|
Executing external programs from within a SAS session on z/OS The following is an excerpt from a SAS 5.18 TS Document (TS-75) entitled ‘Interacting with Your Host System from the SAS System under OS’ by Eric Brinsfield. This section of the paper discusses calling external non-SAS routines from within SAS using the PROC statement. The information contains is still valid; however, please note that calling external routines in this manner is not officially supported. This method works well for calling modules that do not require any information to be passed from the routine back to SAS. If you require that, you should look into using the CALL MODULE call routine. It is more complex, but at the same time is much more flexible. It allows you to pass parameters from the routine back to SAS. It also is fully supported. For more information about using CALL MODULE, please refer to the online documentation. There is another TS-Document (TS-575) which gives z/OS specific information along with examples. You can access TS-575 from the web at http://support.sas.com/techsup/technote/ts575.html. Executing external programs and commandsYou can save system initialization and clean-up time by calling external commands or modules from within the SAS System instead of exiting the SAS environment to execute your non-SAS functions. By using the PROC or TSO statements, you can execute TSO commands, TSO CLISTs, or other programs that are stored as load modules. The PROC statementEntering a PROC statement as PROC xxxx; Instructs the SAS supervisor to search for load module xxxx. The SAS System first searches for the modules in the SASLIB allocation, then in the STEPLIB concatenation, and finally through the system link list libraries. If the module is found but is not a SAS procedure, the supervisor issues a warning and tries to execute it. This works in batch or TSO. SAS procedure load modules are recognized by a hex code stored with the module. The linkage editor allows any programmer to place data in the System Status Index of the directory entry for the load module. Using the SETSSI statement, SAS Institute links load modules with SETSSI data equal to AA000000. If those data are not found as the module is loaded, the SAS System assumes the program is an external non-SAS procedure. You pass parameters to the called program by using the following SAS satatement: OPTIONS PARM=’pppp’; Where pppp is the parameter you need to pass. You cannot pass a parameter back to the SAS system directly using this form of call. You must write the resulting data to another file and then read them in using the SAS language. In the SASLOG, the SAS supervisor prints the return code from the called program. I f you need to return results directly to the SAS DATA step, consider writing a SAS function or CALL routine. For example, the following program demonstrates how to modify all or selected members of a PDS library. First PROC SOURCE unloads the PDS into a temporary sequential file. Then the DATA step reads each line, makes the necessary changes, and writes the line out to a second temporary file. The PROC statement then calls IEBUPDTE to load the modified sequential file back into a PDS. You can accomplish the same sequence of events by executing IEBUPDTE in a separate job step, but the method shown below has advantages if you want to remain in the SAS System. Note that since IEBUPDTE requires exclusive use of the SYSIN DD, you must reassign the input filel for the SAS System. You can accomplish this with the SAS system option SYSIN=INCODE, which instructs SAS to obtain source input from the INCODE DD. In this example, the DATA step reads each input line and determines it’s length. If the line is shorter than 71 characters, the line is output without modification. If the DATA step finds any source line that extends beyond column 70, the line is broken in half at the first blank space past column 35. The two halves are output as two shorter lines in place of the original line.
|