SAS 9.1.3 Integration Technologies » Developer's Guide


SAS Stored Processes
Implementing a Repository
Creating a Stored Process
Invoking a Stored Process
Publishing Stored Process Results
Working with Stored Process Results in the Client Application
IOM Direct Interface Stored Processes

Creating a Stored Process

A SAS language stored process is a normal SAS program with an additional feature that enables you to customize its execution. This feature enables the invoking application to supply name/value parameters at the time that the stored process is invoked. For example, if you have a stored process that analyzes monthly sales data, you could create a MONTH variable in the stored process. Then at execution time, to analyze the May sales data, you would supply a name/value pair of MONTH=MAY.

The following is an example of a stored process:


  %let tempdir = ;

  %let source = ;
  %let intable = ;
  %let svar = ;

  %let filter = ;

  %let outtitle = ;

  *ProcessBody;

  libname datain "&source";

  proc sql;
     create table xQuery as
     select product, &svar
       from datain.&intable
      where &filter;

  proc sort data=xQuery;
  by &svar;

  proc print data=xQuery;
  by &svar;

  filename outgif "c:\Temp\&tempdir\xQuery.gif";
  goptions reset=all;
  goptions device=gif gsfname=outgif gsfmode=replace;
  title1 f=swiss &outtitle;
  proc gchart data=xQuery;
     hbar3d product/sumvar=&svar patternid=midpoint;
  run;

As you can see in the example above, SAS Macro Language variables implement the stored process's execution parameters within the source body. The macro variables are initialized to default values in the prologue section of the stored process. The *ProcessBody comment is a marker that identifies the end of the prologue. This marker is required syntax that delineates the boundary between the default parameter prologue and the source body, where invocation parameters are applied.

The remainder of the stored process is an ordinary SAS program--in this case, a general purpose analysis routine that both prints the results and graphs them in a three-dimensional horizontal bar chart.

When the stored process is executed, the IOM StoredProcessService applies the client-provided name/value parameters that override the default values of the macro variables.