STP Procedure

OUTPUTPARAM Statement

Defines output parameters that are produced by the execution of the stored process

Syntax

OUTPUTPARAM parameter-name<=local-variable-name>;

Required Argument

parameter-name
specifies output parameter names, or specifies output parameters as name/value pairs where the values are local macro variables. Each name or name/value pair is converted to a SAS macro, which can be used in the stored process. The parameter name is the name of the macro variable that contains the parameter value. The parameter name must be a valid macro variable name and cannot be longer than 32 characters in length. You can specify the name of a local macro variable, as follows:
local-variable-name specify the name of a local macro variable that contains the output parameter value. The macro variable is set to the output parameter value at the completion of stored process execution. If local-variable-name is omitted, the parameter name is used as the local variable name. The local variable is not set if the stored process fails to set an output parameter value.

Details

The OUTPUTPARAM statement identifies macros within the stored process environment to retrieve and use in the PROC STP SAS session. You can also create local macros within the PROC STP SAS session and assign the stored process output parameter to it.

Examples

Example 1

The following example retrieves the resultValue macro from the stored process environment and uses it in the PROC STP session. The stored process, outputparam, contains the following code:
…
%let tempVal = 5;
%let tempVal2 = 10;
 
%global resultValue;
%let resultValue = %eval(&tempVal2 + &tempVal);
…
The following PROC STP code is used in the SAS session:
PROC STP PROGRAM="/Users/johndoe/procstp/outparam";
   outputparam resultValue;
run;
 
/* After PROC STP runs, resultValue is set in the stored process 
   and is available in the local SAS environment */
%put NOTE: The Stored Process set resultValue=&resultValue;
The following message appears in the SAS log:
NOTE: The Stored Process set resultValue=15

Example 2

The following example retrieves the resultValue macro from the stored process environment and assigns it to a local variable in the SAS session:
PROC STP PROGRAM="/Users/johndoe/procstp/outparam";
   outputparam resultValue=myLocalResult;
run;
 
%put NOTE: The SAS Session local macro myLocalResult=&myLocalResult;
The following message appears in the SAS log:
NOTE: The SAS Session local macro myLocalResult=15