RUN_SASFILE Function

Executes SAS code in a fileref that you specify.
Category: Calling SAS Code from within Functions

Syntax

rc = RUN_SASFILE('fileref_name' <, variable-1, ..., variable-n>);

Required Arguments

rc
is 0 if the function is able to submit a request to execute the code that processes the SAS file. The return code indicates only that the call was attempted.
fileref_name
specifies the name of the SAS fileref that points to the SAS code.
Requirement:fileref_name must be a string enclosed in quotation marks or a character variable that contains the name of the SAS fileref.

Optional Argument

variable
specifies optional PROC FCMP variables that will be set by macro variables of the same name. These arguments must be PROC FCMP double or character variables.
Before SAS executes the code that references the SAS file, the SAS macro variables are defined with the same name and value as the PROC FCMP variables. After execution, these macro variable values are copied back to the corresponding PROC FCMP variables.

Example

The following example is similar to the first example for RUN_MACRO except that RUN_SASFILE uses a SAS file instead of a predefined macro. This example assumes that test.sas(a, b, c) is located in the current directory.
      /* test.sas(a,b,c) */
data _null_;
   call symput('p', &a * &b);
run;

   /* Set a SAS fileref to point to the data set. */
filename myfileref "test.sas";

   /* Set up a function in PROC FCMP and call it from the DATA step. */
proc fcmp outlib = sasuser.ds.functions;
   function subtract_sasfile(a,b);
   rc = run_sasfile('myfileref', a, b,
p);
   if rc = 0 then return(p);
      else return(.);
   endsub;
run;

options cmplib = (sasuser.ds);
data _null_;
   a = 5.3;
   b = 0.7;
   p = .;
   p = subtract_sasfile(a, b);
   put p=;
run;