Previous Page | Next Page

Submitting SAS Statements

Details of Parameter Substitution

The SUBMIT statement supports two kinds of parameter substitution: full substitution and specific substitution.

Full Substitution

If you want to substitute many values into a SUBMIT block, it can be tedious to explicitly list the name of every SAS/IML matrix that you reference. You can use an asterisk (*) in the SUBMIT statement as a "wildcard character" to indicate that all SAS/IML matrices are available for parameter substitution. This is called full substitution and is shown in the following statements:

proc iml;
DSName = "Sashelp.Class";
NumObs = 1;

submit *;
proc print data=&DSName(obs=&NumObs);
run;
endsubmit;

Figure 10.4 Full Substitution
Obs Name Sex Age Height Weight
1 Alfred M 14 69 112.5

If the SUBMIT block contains a parameter reference (that is, a token that begins with an ampersand (&) for which there is no matching SAS/IML matrix, the parameter reference is not modified prior to being sent to the SAS language processor. In this way, you can reference SAS macro variables in a SUBMIT block.

Specific Substitution

A SUBMIT statement that contains an explicit list of parameters is easier to understand than a SUBMIT statement that contains only the asterisk wildcard charater (*). Specifying an explicit list of parameters is called specific substitution. These—and only these—parameters are used to make substitutions into the SUBMIT block.

proc iml;
DSName = "Sashelp.Class";
NumObs = 2;

submit DSName NumObs;
proc print data=&DSName(obs=&NumObs);
run;
endsubmit;

Figure 10.5 Specific Substitution
Obs Name Sex Age Height Weight
1 Alfred M 14 69.0 112.5
2 Alice F 13 56.5 84.0

If the SUBMIT block contains a parameter reference (that is, a token that begins with an ampersand (&) for which there is no matching parameter, the parameter reference is not modified prior to being sent to the SAS language processor. In this way, you can reference SAS macro variables in a SUBMIT block.

With specific substitution, you have additional options for specifying the value of a parameter. You can use any of the following ways to specify the value of a parameter:

  • Specify the name of a SAS/IML matrix to use for the value of a parameter, as shown in the following statements:

    s = "Sashelp.Class";
    n = 2;
    
    submit DSName=s NumObs=n;
    proc print data=&DSName(obs=&NumObs);
    run;
    endsubmit;
    
  • Specify a literal value to use for the value of a parameter, as shown in the following statements:

    submit DSName="Sashelp.Class" NumObs=2;
    proc print data=&DSName(obs=&NumObs);
    run;
    endsubmit;
    
  • Specify a matrix expression that is enclosed in parentheses, as shown in the following statements:

    libref = "Sashelp";
    fname  = "Class";
    NumObs = 2;
    
    submit DSName=(libref+"."+fname) NumObs;
    proc print data=&DSName(obs=&NumObs);
    run;
    endsubmit;
    
Previous Page | Next Page | Top of Page