STP Procedure

INPUTFILE Statement

Defines input files for the execution of the stored process

Syntax

Required Argument

stored-process-file
specifies the name of an input 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 input file in one of the following ways:
local-fileref specify the name of a local fileref. The contents of the fileref are read and copied to a temporary fileref and then made available to the stored process. The short form of the INPUTFILE statement, INPUTFILE stored-process-file;, is equivalent to INPUTFILE 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 input files in metadata before the INPUTFILE statement can be used. Multiple INPUTFILE statements can be specified in a single procedure call.

Examples

Example 1

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

Example 2

The following example passes a fileref by its local name:
filename incsv 'c:\johndoe\data\class.csv';
 
PROC STP PROGRAM="/Users/johndoe/procstp/readCSV";
   inputfile incsv;  
run;
The stored process readCSV looks like the following code:
/* Take CSV file and put it into a data set */
proc import datafile="%sysfunc(pathname(incsv))"
      out=work.mydata dbms=csv replace;
   getnames=yes;
run; quit;
 
/* Run PROC MEANS on the data set created from the CSV file */
proc means data=work.mydata n mean stddev;
   class sex;
   var age height weight;
run; quit;
 
...

Example 3

You can also pass an input file to a stored process via another name or by using a file system path. In the following two examples, the stored process accesses the fileref by the name incsv:
filename localfref 'c:\johndoe\data\class.csv';
 
PROC STP PROGRAM="/Users/johndoe/procstp/readCSV";
   inputfile incsv=localfref;  
run;

Example 4

PROC STP PROGRAM="/Users/johndoe/procstp/readCSV";
   inputfile incsv='c:\johndoe\data\class.csv';  
run;