THE SAS® STORED PROCESS - UNLEASHING THE POWER OF SAS
We all know that SAS delivers fast and accurate forecasts. Many of you get forecasts on demand from a SAS interface such as SAS Enterprise Guide, the SAS Information Delivery Portal or Display Manager. The true power of SAS is unleashed when these results are reviewed and acted on by the right people at the right time.But of course there are more and more of the "right people". With the business benefits of forecasting and optimisation now widely accepted, this has fuelled the demand for wider access to such processes - and it's not just people, either.
Imagine, for example, the benefits of a supply chain management system that automatically requests a forecast on stock levels if an order reduces holdings of a product to less than half. Or a credit risk management system that triggers fraud analysis of certain banking transactions. In such cases the systems don't want a report, printable or otherwise: they want data in a form they can process. Whether we need to deliver results to a person or a system, what we're trying to achieve is a service that returns results in the right form to the requester.Enter the SAS Stored Process, one of the most powerful new tools in the SAS®9 architecture. It's a SAS program that is stored on a server and registered in metadata. And it will do pretty much anything: you're only limited by what you know about the SAS language and the SAS modules you have. It could be 10,000 lines of code or 10, it could be DATA and PROC steps or SQL. It could be calling a complex optimisation routine or a simple print, and what it returns could be PDF, HTML or XML or any other output format that SAS supports.
SAS® Stored Processes SAS Stored Processes can be accessed in a number of ways. SAS clients such as SAS Enterprise Guide, SAS Web Report Studio, the Add-In for Microsoft Office and the SAS Information Delivery Portal can call stored processes automatically. They have interfaces that will search the metadata server and present lists of available stored processes to the user. SAS Stored Processes developed for this purpose typically have a structure as follows:
*ProcessBody; %stpbegin; proc print data=SASHELP.CLASS; run; %stpend;
The comment is required as it defines the separator between the prologue and the process body. The two macros ensure the correct ODS options are applied according to the requesting client: it will apply ODS HTML if the calling client is a web interface and ODS RTF if the calling client is MS Word, and so on. See http://support.sas.com/documentation/cdl/en/stpug/62758/HTML/default/viewer.htm#n0nsj5vk0huz6yn15ohrpmwk2812.htm.Adding user-defined parameters will enhance these stored processes. For instance, in the previous example we might want the user to define gender:
The stored process itself will probably look like:
%global gender; ODS HTML file=_webout; proc print data=SASHELP.CLASS; where sex="&gender"; run; ODS HTML close;
In a simple stored process like this, you could still use the %stp macros. Stored Process Web applications are often chained together, such that the first stored process presents a HTML form for the user to select the parameters, and then links to a second stored process that generates the results. In these cases it's often preferable to use ODS as it offers more flexibility and the developer is less concerned about the type of client that's making the request. Special macro variables are available within the web application to allow session management (maintaining state between calls) that can be important for efficiency. Some understanding of HTML is helpful in these cases but ODS hides much of the complexity.You can find more examples of Stored Process Web Applications at:
It's clear that your investments in SAS can be greatly enhanced by providing the benefits of optimisation and forecasting to every part of the business - and that can be enabled in part by the powerful new interfaces in the SAS Business Intelligence Server Solution. The Stored Processes, however, extend the capability into all areas of the business.
Note: SAS Stored Processes is only available as part of SAS Integration Technology, Business Intelligence Server or Enterprise Business Intelligence Server. Service Oriented Architectures and Web Services will be covered in more detail in a future edition of In The Know.
Did you find this page useful?
If you have any comments or questions, feel free to contact us.