The SUBMIT Statement

IMLPlus enables you to execute SAS language statements within an IMLPlus program. The SAS language statements may consist of the following:

The subject of executing SAS language statements within IMLPlus programs is discussed in detail in the section Accessing SAS Functionality.

The mechanism by which an IMLPlus program submits SAS language statements is the SAS class. The most frequently used method in the SAS class is SubmitStatements. This method passes a string containing one or more SAS language statements to the SAS server for processing. IMLPlus provides a very convenient shortcut for calling the method SAS.SubmitStatements: the SUBMIT statement. When IMLPlus encounters a SUBMIT statement, it passes the program source code between the SUBMIT statement and the following ENDSUBMIT statement to the method SAS.SubmitStatements. (Note that it is still necessary to call the method SAS.SubmitStatements directly in situations where the IMLPlus program builds SAS language statements dynamically.)

The SUBMIT and ENDSUBMIT statements define a SUBMIT block. The syntax for a SUBMIT block is:

submit [substitutions] [/ ok=ok-matrix];

    SAS-language-statements

endsubmit;

The user-definable elements are as follows:

substitutions
Specifies optional parameter substitutions. The substitutions argument enables you to substitute the values of IMLPlus program variables for parameter references in the SUBMIT block. To specify a parameter reference in the SAS-language-statements text, prefix the name of the parameter with an ampersand (&). If you do not specify the substitutions argument, IMLPlus submits the SAS-language-statements text without modifying it in any way.

ok-matrix
Specifies a matrix variable that IMLPlus sets to 1 if the submitted statements execute without error and to 0 otherwise.

SAS-language-statements
Specifies one or more SAS language statements.

Example:

submit;
    proc print data=SASHELP.PRDSALE;
    run;
endsubmit;

Using the OK Option

The OK option provides a limited form of error handling. If you do not specify the OK option and the submitted statements encounter an error, IMLPlus stops the program and issues an error. If you do specify the OK option, IMLPlus sets the variable ok-matrix to 1 if the submitted statements execute without error and to 0 otherwise. If IMLPlus sets the variable ok-matrix to 0, IMLPlus does not stop the program. IMLPlus assumes the program will examine the variable ok-matrix and handle the error appropriately.

IMPORTANT: If you use the OK option with an interactive procedure such as REG, GLM, or CATMOD, you must end the PROC step with the QUIT statement instead of the RUN statement. Otherwise, IMLPlus will set the variable ok-matrix to 1 even if the procedure encounters an error.

When using the OK option to detect errors, it is sometimes useful to call the Base SAS function SYMGETN to read the value of the SYSERR macro variable. Most SAS procedures set the value of the SYSERR macro variable when they encounter an error.

Example:

submit / ok=ok;
    proc print data=SASHELP.PRDSALE;
    var Undefined;
    run;
endsubmit;

print ok;
rc = symgetn( "syserr" );
if rc = 116 | rc = 1016 then
    print "The procedure ran out of memory.";
if rc = 3000 then
    print "A syntactic error occurred.";

Submitting SAS Global Statements

IMLPlus provides a shortcut for situations in which you need to submit a single SAS global statement without using substitution. If you prefix the SAS global statement with the @ character, IMLPlus will submit the statement (minus the @ character) to the method SAS.SubmitStatements.

Example:

@catname _ALL_ list;

Note that as of IML Studio 12.3 IMLPlus supports the following SAS global statements as native IMLPlus statements: FILENAME, FOOTNOTE, LIBNAME, ODS, OPTIONS, TITLE. It is therefore not necessary to prefix these statements with the @ character.

Details Concerning Substitution

IMLPlus provides two forms of substitution within SUBMIT blocks: full substitution, and specific substitution.

Full Substitution

With full substitution, IMLPlus attempts to replace each parameter reference in the SAS-language-statements text with the value of the program variable that has the same name as the parameter. If no such program variable exists, IMLPlus passes the parameter reference through to SAS unmodified because it could be a reference to a SAS macro variable. IMLPlus performs full substitution when the substitutions argument is an asterisk (submit *;).

Example:

libref  = "SASHELP";
dataset = "PRDSALE";

submit *;
    proc print data=&libref.&dataset;
    run;
endsubmit;
Specific Substitution

Specific substitution enables you to have more control over the substitutions that IMLPlus performs. With specific substitution, the substitutions argument lists the parameters for which IMLPlus should perform substitution. Any parameter reference in the SAS-language-statements text for which the parameter is not listed in the substitutions argument is passed through to SAS unmodified because it could be a reference to a SAS macro variable. If the substitutions argument lists multiple items, each item must be separated by one or more white space characters (space, tab, newline).

Example:

libref  = "SASHELP";
dataset = "PRDSALE";

submit libref dataset;
    proc print data=&libref.&dataset;
    run;
endsubmit;

With specific substitution, you have the following additional options for substituting a parameter: