Tips for running a SAS® Stored Process in Background mode


If you have a SAS® Stored Process that creates non–streaming output and you submit the SAS Stored Process using a Web browser, you can run the request in the foreground (the default) or in the background. Here are some notes about running a SAS Stored Process in the background using SAS® 9.2 and later releases.

  1. By default, a SAS Stored Process runs in the foreground and your Web browser will wait to receive the output until the SAS Stored Process completes execution. However, if you run a SAS Stored Process in the background, control is returned to your Web browser when the SAS Stored Process is submitted for execution.
  2. To execute the SAS Stored Process in background mode, you must add the _ACTION=BACKGROUND option to the SAS Stored Process execution using one of the following approaches:
    1. Add the _ACTION=BACKGROUND option directly to the URL for the SAS Stored Process. See the following example:
      http://your-server:8080/SASStoredProcess/do?_program=/MySTPs/test&_action=background

      Multiple values for the _ACTION= parameter are separated by a comma, as in the following example:

http://your-server:8080/SASStoredProcess/do?_program=/MySTPs/test&_action=strip,background

2. If the SAS Stored Process has input parameters that require end user selections before submitting the SAS Stored Process, you can define _ACTION=BACKGROUND as a hidden input parameter for the SAS Stored Process definition in metadata. Note: the metadata–defined _ACTION=BACKGROUND hidden parameter is only used if the SAS Stored Process is submitted using the Property page supplied by SAS. In other words, this approach requires that there be other visible input parameters defined in metadata that the end user must select before running the SAS Stored Process.

For example, create a SAS Stored Process with two input parameters. One parameter is _action (NOTE: the name of the parameter, _action, must be specified in LOWER CASE) with default value of BACKGROUND (case insensitive) and the checkbox to "Hide from user" selected and the other parameter is AGE with values from 11 to 16 in a static list. The SAS Stored Process code is:

%stpbegin;
proc print data=sashelp.class;
where age=&age;
run;
%stpend;

When this SAS Stored Process is submitted from the SAS Property page, it will be executed in the background.

3. If the SAS Stored Process does not require user interaction for input parameter selection, you can create a custom jsp file that automatically submits the SAS Stored Process with _ACTION=BACKGROUND, as in the following example:

<html><body onLoad="document.mystp.submit()"> <form name=mystp action="<%= request.getContextPath() %>/do"> <input type="hidden" name="_program" value="/MySTPs/test"> <input type="hidden" name="_action" value="background"> </form></body></html>

3. Running a SAS Stored Process in the background causes an alert to be created. You can view your alerts (and any results from the SAS Stored Process) from the Stored Process Alerts Portlet in the SAS® Information Delivery Portal.

4. In the SAS Information Delivery Portal, the following portlets are helpful when running SAS Stored Processes in background mode.

    1. The Stored Process Alerts Portlet

Follow these steps to add the Stored Process Alerts Portlet to your SAS Information Delivery Portal Page:

      1. Select Options ► Edit Page Content ► Add Portlets.
      2. On the Add Portlets page, click Search and search for the Stored Process Alerts Portlet.
      3. Check the Stored Process Alerts Portlet box.
      4. Click Add and then click Done and OK.
    1. The Personal Repository Navigator.

You can use the Personal Repository Navigator to access your Personal Repository (which resides on the SAS Content Server).

Follow these steps to add the Personal Repository Manager to your SAS Information Delivery Portal Page:

      1. Select Options ► Edit Page Content ► Add Portlets.
      2. On the Add Portlets page, click Search and search for the Personal Repository Navigator.
      3. Check the Personal Repository Navigator box.
      4. Click Add and then click Done and OK.

 

3. The WebDAV Navigator

Follow these steps to add the WebDAV Navigator to your SAS Information Delivery Portal page:

        1. Select Options ► Edit Page Content ► Add Portlets.
        2. Under the Portlet type pulldown, select WebDAV Navigator.
        3. Click Add and then click Done and OK.

5. When the SAS Stored Process is submitted, a message is returned to the browser window stating:

Stored Process <stored process name> submitted for background processing.

6. When the SAS Stored Process competes execution, the following items occur:

    1. An alert message is added in the Stored Process Alert Portlet. You can click on the alert message to see your output.
    2. The output is stored on the SAS Content Server at:
      /sasdav/Users/<user name>/PR/MyDocuments
    3. You can also access your output via a Web browser outside of the SAS Information Delivery Portal. For example, using your Web browser, reference an address similar to the following (where you specify your site–specific Web server and user account):
http://your-server:8080/SASContentServer/repository/default/sasdav/Users/<user name>/PR/MyDocuments

Then, select your *.spk output file, save it as a *.zip file and open it with a utility such as WinZip.

7. For more information, see the following resources: