SUBMIT Statement

SUBMIT <parameters> </ options> ;

language statements

ENDSUBMIT ;

The SUBMIT statement enables you to submit SAS statements for processing from within a SAS/IML program. You can use the SUBMIT statement to call SAS procedures, DATA steps, and macros. All text between the SUBMIT statement and the ENDSUBMIT statement are referred to as a SUBMIT block. The SUBMIT block is processed by the SAS language processor.

If you use the R option, the SUBMIT statement enables you to submit statements to the R language for processing.

The SUBMIT statement must appear on a line by itself. All SAS/IML matrices that are defined prior to the SUBMIT statement remain defined after the ENDSUBMIT statement.

parameters

specifies one or more optional SAS/IML matrices whose values are substituted into the language statements in the SUBMIT block. To reference a parameter in the SUBMIT block, prefix the name of the parameter with an ampersand (&). If you do not specify the parameters argument, the SUBMIT block is sent without modification to the SAS (or R) language processor.

The following options are available in the SUBMIT statement after a slash (/).

OK=ok-matrix

specifies the name of a matrix. The matrix is set to 1 if the SUBMIT block executes without error, and to 0 otherwise.

R

specifies that statements in the SUBMIT block are processed by the R statistical software. You can use the R option to call functions in the R language, provided that the following statements are true:

  1. the R statistical software is installed on the SAS workspace server.

  2. The SAS system administrator at your site has enabled the RLANG SAS system option. (See the section The RLANG System Option.)

The following example calls a SAS procedure from a PROC IML program. The example passes in a parameter which is used by the FREQ procedure:

proc iml;
VarName = "Sex";
submit VarName;
proc freq data=Sashelp.Class;
   table &VarName / out=OutFreq;
run;
endsubmit;

Prior to the SUBMIT statement, the program defines the VarName matrix. The matrix contains the name of a variable in the Sashelp.Class data set. The VarName matrix is listed in the SUBMIT statement, which means that the contents of the matrix is available for substitution into the SUBMIT block. The SUBMIT block references the contents of the matrix by preceding the matrix name by an ampersand (&). Consequently, the FREQ procedure carries out a one-way frequency analysis for the Sex variable. The output from PROC FREQ is shown in Figure 24.398.

Figure 24.398: Result of Calling a SAS Procedure

The FREQ Procedure

Sex Frequency Percent Cumulative
Frequency
Cumulative
Percent
F 9 47.37 9 47.37
M 10 52.63 19 100.00


The preceding statements also create output data set, OutFreq. The following statements read the data into SAS/IML matrices:

use OutFreq;
read all var VarName into Levels;
read all var {Count};
close OutFreq;

print Count[rowname=Levels];

Notice that the VarName matrix is still defined, even after the FREQ procedure has finished execution. The statements read portions of the PROC FREQ output data set into two SAS/IML vectors. The output from the program is shown in Figure 24.399.

Figure 24.399: Result of Calling a SAS Procedure

COUNT
F 9
M 10


Chapter 10: Submitting SAS Statements, provides details and further examples of submitting SAS statements. Chapter 11: Calling Functions in the R Language, describes how to submit R statements and provides examples.

You cannot use the SUBMIT statement in code that is pushed to the input command queue with the EXECUTE, PUSH, or QUEUE subroutines.