STP Procedure

OUTPUTDATA Statement

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

Syntax

Required Argument

stored-process-data-file
specifies the name of an output data file that is defined by the stored process metadata. This name corresponds to an output parameter (macro variable) that is visible to the stored process program. Specify the name of the output data file in one of the following ways:
member-name specify a one- or two-level name of a SAS data set or view. The stored process accesses the data file directly through a temporary libref.
“data-set-path” provide alternate syntax for specifying a local data set. As with the member-name syntax, the stored process accesses the data file directly through a temporary libref.

Details

The stored process must be defined to use output data files in metadata before the OUTPUTDATA statement can be used. Multiple OUTPUTDATA statements can be specified in a single procedure call. PROC STP prepends the OUTPUTDATA label with _TARGET_, in order to be compliant with how data targets are handled in SAS Management Console.

Examples

Example 1

The following example executes a stored process with two output data files, demonstrating different use cases for the OUTPUTDATA statement:
proc stp program="/Products/SAS Intelligence Platform/Samples/
      Example Stored Process";
   OUTPUTDATA DATA1=MYLIB.MYDATA;           /* output data file DATA1 is 
                                               created as MYLIB.MYDATA */
   OUTPUTDATA DATA3="/tmp/mydata.sas7bdat"; /* output data file DATA3 is 
                                               created at the specified 
                                               path */
   ...
   RUN;

Example 2

The following example shows the interaction between PROC STP and the stored process:
/* Create a libref in the proc stp environment */
libname mylib 'c:\johndoe\temp';

/* Run a stored process that creates a dataset */
PROC STP PROGRAM="/Users/johndoe/procstp/createData";
   /* Pass in a reference, "outdata" to the dataset */
   outputdata  outdata=mylib.employees;

run;

/* After the stored process creates the dataset, 
   print it in our local environment */
proc print data=mylib.employees;
   Title 'Our Employees';
run;
quit;
The following code is the createData stored process that creates the data set. Notice that in this example, PROC STP has modified outdata to be _TARGET_outdata. Within this stored process, the code uses the _TARGET_outdata data set reference that was passed in by PROC STP:
data &_TARGET_outdata;
   length First_Name $8 Last_Name $9 Job_Title $8;
   input First_Name $ Last_Name $
         Job_Title $ Salary;
   datalines;
Joshua Alexander Auditor 41423
Gabriel Ryan Trainee 26018
Eileen Joy Manager 55236
Richard Collier CEO 75000
;
run;

Example 3

The following example uses the PROC STP WORK library with the OUTPUTDATA statement:
/* Run a stored process that creates a dataset */
PROC STP PROGRAM="/Users/johndoe/procstp/createData";
   /* Pass in a reference, "outdata" to the dataset */
   outputdata  outdata=work.employees;

run;

/* After the stored process creates the dataset, 
   print it in our local environment */
proc print data=work.employees;
   Title 'Our Employees';
run;
quit;