SAS Institute. The Power to Know

Create a SAS Program File for a Stored Process


Overview of Writing Stored Processes

A stored process is a specialized SAS program file that is stored on a server. All SAS stored process code must conform to the following requirements:


Basic Example: Returning ODS Output

For example, the following code prints a data set:

*ProcessBody;
%stpbegin;
proc print data=sashelp.class;
run;
%stpend;

The streaming output appears in your default Web browser.


Retrieving Data Sets in a Stored Process

You can use the _WEBOUT fileref to request that ArcMap retrieve data sets. To send a data retrieval message, put a message with the following format to the _WEBOUT fileref: indicator-tag, libref.data-set. The indicator tag is a signal identifies a data set request to Bridge for ESRI. You can use the Data set indicator tag option in SAS Bridge for ESRI to specify the tag value. For example, the following code uses the default data set indicator tag _SBFEds to return a SAS data set to ArcMap:

*ProcessBody;
data _null_;
  file _WEBOUT;
  %let myvar= '_SBFEds, SASHELP.RETAIL';
  put &myvar;
run;

SAS Bridge for ESRI creates an OLE DB connection to retrieve the SASHELP.RETAIL data set. If the Show results in table of contents option is enabled, then the SASHELP.RETAIL data set appears on the Source tab of the Table of Contents pane in ArcMap.

Note:The data set that you retrieve must be from a persistent library such as SASHELP. You cannot retrieve data from temporary libraries such as WORK.


Using Layer Data in a Stored Process

To receive layer data from ArcGIS, the stored process must create an XML libref with an XMLTYPE of GENERIC. For example:

libname instream xml xmltype=generic;

If you have created an XML libref for the ArcGIS data, then you can use the &Layer macro variable to refer to the layer that is selected in ArcMap. For example, the following code prints the selected label:

*ProcessBody;
%stpbegin;
libname instream xml xmltype=generic;
proc print data=instream.&Layer;
run;
%stpend;

More Information

For more information about writing stored processes, see the SAS Stored Processes Developer's Guide at http://support.sas.com/documentation/onlinedoc/inttech/index.html.