SAS Stored Processes
Stored Process SamplesThe following samples demonstrate how a stored process generates different types of output using the *ProcessBody; %STPBEGIN; title 'Age analysis by sex'; footnote; proc sort data=sashelp.class out=class; by sex age; run; proc gchart data=class; vbar3d age / group=sex discrete nozero shape=cylinder patternid=group; run; quit; title; proc print data=class; by sex age; id sex age; var name height weight; run; %STPEND; This code generates a bar chart and a table. The exact format and appearance of the output depends upon various input parameters. For these samples, assume the following input parameters were specified:
Note: See the section on Reserved Macro Variables for a more detailed description of each macro variable mentioned in the previous table and in the following sections. Streaming OutputStreaming output is generally used when you are executing a stored process from a Web-based application using the SAS Stored Process Web Application or when you are returning a single output file with no embedded links to companion files such as images. Because the stored process was registered with a result type of
The HTML output from the stored process is streamed to the client though the server-created _WEBOUT fileref. The PNG image file is streamed through a separate replay connection to the server, as described in the section on Embedding Graphics. Creating a Transient PackageTransient packages are a convenient way to deliver a collection of multiple output files to a client application. Transient packages are implemented in different ways for the stored process server and the workspace server as described in the following sections. Stored Process ServerA stored process registered with a result type of
Workspace ServerThe same stored process registered on a workspace server is executed with _RESULT set to
Creating a Permanent Package ArchivePermanent packages are published to a permanent location where they can be accessed at a later time. Permanent packages are also immediately available to the stored process client through the same interfaces used for a transient package. This sample assumes that the stored process was registered with the following metadata, in addition to the parameters already listed:
Again, implementation differs between the stored process server and the workspace server. _RESULT is set to
The archive package is created at Creating a Permanent Package on a WebDAV ServerPermanent packages can also be published to WebDAV servers by specifying the appropriate options when registering the stored process. This sample assumes that the stored process was registered with the following metadata, in addition to the parameters already listed:
The input parameters are as follows:
The package is created in a uniquely named collection under Publishing a Package to E-MailAs discussed in the section on Advanced Package Publishing, packages can be published to other destinations with minor modifications to the stored process. Adding two lines to the stored process such as *ProcessBody; %let _RESULT=PACKAGE_TO_EMAIL; %let _ARCHIVE_PATH=TEMPFILE; %STPBEGIN; title 'Age analysis by sex'; footnote; proc sort data=sashelp.class out=class; by sex age; run; proc gchart data=class; vbar3d age / group=sex discrete nozero shape=cylinder patternid=group; run; quit; title; proc print data=class; by sex age; id sex age; var name height weight; run; %STPEND; and registering the stored process with
The package is created and mailed to the |