STP Procedure

OUTPUTFILE Statement

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

Syntax

Required Argument

stored-process-file
specifies the name of an output file that is defined by the stored process metadata. This name corresponds to a fileref that is visible to the stored process program. You can specify the name of the output file in one of the following ways:
local-fileref specify the name of a local fileref. The contents of the stored process output file are copied to this fileref. The short form of the OUTPUTFILE statement, OUTPUTFILE stored-process-file;, is equivalent to OUTPUTFILE stored-process-file=stored-process-file;.
“local-file-path” specify the path of a local file. A fileref is assigned for the stored process to access the file directly.

Details

The stored process must be defined to use output files in metadata before the OUTPUTFILE statement can be used. Multiple OUTPUTFILE statements can be specified in a single procedure call.

Examples

Example 1

The following example executes a stored process with three output files, demonstrating different use cases for the OUTPUTFILE statement:
PROC STP PROGRAM="/Products/SAS Intelligence Platform/Samples/
      Example Stored Process";
   ...
   OUTPUTFILE FILE1;                   /* copies data from stored process FILE1 
                                          fileref to local FILE1 fileref */
   OUTPUTFILE FILE2=MYFILE;            /* copies data from stored process FILE2 
                                          fileref to local MYFILE fileref */
   OUTPUTFILE FILE3="/tmp/data3.csv";  /* copies data from stored process FILE3 
                                          fileref to specified local file */
   ...
   RUN;

Example 2

The following example writes stored process output to a file by using a local file path:
PROC STP PROGRAM="/Users/johndoe/procstp/hello";
   outputfile _webout='c:\johndoe\data\hello.html';
run;
The stored process writes HTML code to the _WEBOUT fileref that is passed in by PROC STP:
data _null_;
   file _webout;
   put '<HTML>';
   put '<HEAD><TITLE>Hello World!</TITLE></HEAD>';
   put '<BODY>';
   put '<H1>Hello World!</H1>';
   put '</BODY>';
   put '</HTML>';
run;

Example 3

The following example uses a local fileref with the same name as the reference in the stored process:
filename _webout 'c:\johndoe\data\hello.html';
 
PROC STP PROGRAM="/Users/johndoe/procstp/hello";
   outputfile  _webout;
run;

Example 4

The following example uses a local fileref with a different name from the reference in the stored process:
filename myfile 'c:\johndoe\data\hello.html';
 
PROC STP PROGRAM="/Users/johndoe/procstp/hello";
   outputfile  _webout=myfile;
run;