SAS 9.1.3 Integration Technologies » Developer's Guide


SAS BI Web Services

Writing SAS Programs for Web Services

To use the Web service to call your SAS code, you must configure your SAS code as a stored process. The stored process used with Web Services needs to conform to a few rules which enable the Web service to both receive data from the client and return data to the client.

You can author a stored process manually by using SAS or a text editor to write the code and then registering the program through SAS Management Console. Alternatively, you can use a program such as Enterprise Guide or another SAS code generator to author a stored process using the "point-and-click" method. Use the modifications below to make a stored process that can be used with SAS BI Web Services. Keep in mind that SAS BI Web Services can only return data; no images can be returned.

SAS programs are stored in external files that usually have a .SAS filename extension in directory-based operating environments. For z/OS, the files must be contained in a partitioned data set (PDS). SAS programs can contain a DATA step, procedures, and macro code.

The following list explains unique details about Web service stored processes:

The following example code displays a stored process used as a Web service.

   libname instream xml;
   libname _WEBOUT xml xmlmeta=&_XMLSCHEMA;

   proc means data=instream.&tablename;
      output out=_WEBOUT.mean;
   run;

The first LIBNAME statement in the sample code defines the input stream. This code corresponds to the definition of the input stream in the Streaming Details dialog box in BI Manager. The name of the input stream is instream. In this example, the input stream provides the data to run PROC MEANS against.

The second LIBNAME statement in the sample code defines the output for the stored process as streaming output, or _WEBOUT. In BI Manager, Streaming is specified as the type of output on the Execution tab of the Stored Process Properties dialog box.

The &tablename in the sample code defines a parameter called tablename. In BI Manager, this parameter is specified through the Add Parameter dialog box, and can be modified using the Modify Parameter dialog box. In this example, tablename is a string parameter that specifies the name of the table to run PROC MEANS against.

Note: The dialog boxes mentioned in the previous example are available from both the Stored Process Properties dialog box and the New Stored Process Wizard, which are both part of BI Manager. For more information about using BI Manager to define metadata for stored processes, see the product Help.