SAS 9.1.3 Integration Technologies » Developer's Guide

SAS Stored Processes
Software Requirements
Creating Stored Processes
Input Parameters
Result Types
Reserved Macro Variables
Stored Process Server Functions
Converting SAS/IntrNet Programs
Using Stored Processes
Building a Web Application
SAS Stored Process Web Application
HTTP Headers
Embedding Graphics
Chaining Stored Processes
Using Sessions
IOM Direct Interface Stored Processes
SAS Stored Processes

Creating Stored Processes

A stored process is a SAS program that is hosted on a server and described by metadata. Stored processes can be written by anyone who is familiar with the SAS programming language or with the aid of a SAS code generator such as SAS Enterprise Guide. The basic steps to creating a stored process are as follows:

  1. Writing the Stored Process
  2. Choosing or Defining a Server
  3. Registering the Metadata

Writing the Stored Process

Almost any SAS program can be a stored process. A stored process can be written using the SAS program editor, SAS Enterprise Guide, or any text editor. The following program is a typical stored process:

   title "Shoe Sales By Region and Product";

   proc report nowindows;
      column region product sales;
      define region / group;
      define product / group;
      define sales / analysis sum;
      break after region / ol summarize suppress skip;

The program begins with a standard comment that initiates input parameter processing, if any. The %STPBEGIN and %STPEND macros initialize the Output Delivery System (ODS) and deliver the output (in this case, a report) to the client. This stored process is capable of generating multiple output formats including HTML, XML, PDF, CSV, and custom tagsets and then delivering the output through various techniques including streaming output, a client package, a server-side archive package, or a WebDAV collection.

Note: You should not use the %STPBEGIN and %STPEND macros if your stored process does not use ODS or if your stored process writes directly to the _WEBOUT fileref.

Choosing or Defining a Server

You must choose a server to host your stored process. Servers are defined in metadata and are actually logical server definitions that can represent one or more physical server processes. There are many options including pre-started servers, servers started on demand, and servers distributed across multiple hardware systems. You can use the Server Manager in SAS Management Console to create or modify server definitions. For more information about server configurations, see SAS Integration Technologies: Server Administrator's Guide.

Because the logical server description in metadata hides the server implementation details, a stored process can be moved to or associated with any appropriate server without modifying the stored process. Moving a stored process from one server to another requires only changing the metadata association and moving the source code if necessary. Note that a stored process is the combination of a SAS program, the server that hosts that program, and the metadata that describes and associates the two. It is not possible to create a stored process that is associated with more than one server, although it is possible to create stored processes that share the same SAS program, or source code file.

Stored processes can be hosted by two types of servers: SAS Stored Process Servers and SAS Workspace Servers. The two servers are similar, but have different capabilities and are targeted at different use cases.

Stored Process Server

The stored process server is a multi-user server. A single server process can be shared by many clients. The recommended load-balancing configuration enables client requests to be serviced by multiple server processes across one or more hardware systems. This approach provides a high-performance, scalable server, but imposes some restrictions. Because the same server handles requests from multiple users, it cannot easily impersonate that user to perform security checks. By default, the server runs under a single, shared user identity (defined in metadata) for all requests. All security checks based on client identity must be performed in the stored process. For more information about stored process server security, refer to the section about Planning Security on Workspace and Stored Process Servers.

The stored process server implements several features that are not available on the workspace server, including streaming output, sessions, and multiple-value input parameters. Stored process Web services are only supported on the stored process server.

Workspace Server

The workspace server is a single-user server. A new server process is started for each client. This approach is not as scalable as the load-balanced stored process server, but it has a major security advantage. Each server is started under the client user identity and is subject to host operating environment permissions and rights for that client user. The workspace server also provides additional functionality, including data access and execution of client-submitted SAS code. For more information about workspace server security, refer to the section about Planning Security on Workspace and Stored Process Servers.

Some features available on the stored process server are not available on the workspace server, as described in the previous section. Information map stored processes are supported only on the workspace server.

Using Source Code Repositories

Stored processes are stored in external files with a .sas extension. The .sas file must reside in a directory that is registered with the server that executes the stored process. These directories are known as source code repositories. Source code repositories are managed using BI Manager. After you choose a server for your stored process in BI Manager, you are presented with a list of available source code repositories. You can choose an existing source code repository or click Manage to add or modify source code repositories.

For z/OS, the program can be contained in an HFS .sas file or in a member of a partitioned data set (PDS). Source code repositories can be either HFS directories or a partitioned data set.

Registering the Stored Process Metadata

After you write the stored process and define or choose a server, you must register the metadata using BI Manager. (SAS Enterprise Guide users can perform the same steps within the Enterprise Guide application.) The New Stored Process Wizard can be used to create new stored processes, or you can use the Stored Process Properties dialog box in BI Manager to modify existing stored processes. BI Manager enables you to specify and manage the following information for stored processes:

specifies a collection of stored processes. The folders are defined in metadata and do not correspond to any physical location. The folder hierarchies used for stored processes can also hold SAS reports, information maps, and administrative metadata. You can create and modify folders using BI Manager.

specifies the stored process name, which acts as both a display label and as part of the URI for the stored process.

specifies an optional text description of the stored process.

specifies an optional list of keywords to associate with the stored process. Keywords are arbitrary text strings typically used for searching or to indicate specific capabilities. For example, the keyword XMLA Web Service is used to indicate a stored process that can be executed by SAS BI Web Services.

SAS server
specifies the server that executes the stored process.

Source Code Repository and Source Code File
specifies the directory and source code file containing the stored process.

specifies an optional list of input streams. Input streams can be used to send data that are too large to be passed in parameters from the client to the executing stored process.

specifies the stored process result type.

specifies an optional definition of parameters.

specifies access controls for the stored process. Currently only the ReadMetadata and WriteMetadata permissions are honored. A user must have ReadMetadata permission to execute the stored process. WriteMetadata permission is required to modify the stored process definition.

You are now ready to use the stored process from a variety of clients including the SAS Stored Process Web Application, the SAS Information Delivery Portal, the SAS Add-In for Microsoft Office, SAS Enterprise Guide, and user-written Java applications and JSPs.