Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next

Tabulate Procedure

This sample illustrates the computational power of the Application Dispatcher. The HTML form provides options that perform different tabulations of the same set of data. This capability is possible because the Dispatcher is more than just a data server.


The Input Component

The HTML page for the Tabulate Procedure application is quite simple. It contains a

This sample application uses the HTML Tabulate Formatter, one of the HTML Formatting Tools that is provided by SAS, to create an HTML-formatted table. This tool will produce all of the HTML output for this application! The user interface is simple, but the capabilities that it highlights are very noteworthy. By selecting the various check boxes, the user controls which variables will be tabulated in the resulting table.

The check boxes on this form allow users to select the statistics to display. Check boxes are created by using the INPUT tag that has a type of CHECKBOX. Here is the code for the four check boxes on this page:

   <INPUT TYPE="checkbox" NAME="n" VALUE="n*f=8." CHECKED>Number of Sales
   <INPUT TYPE="checkbox" NAME="mean" VALUE="mean*f=dollar12." CHECKED>Average Sale
   <INPUT TYPE="checkbox" NAME="min" VALUE="min*f=dollar14.">Smallest Sale
   <INPUT TYPE="checkbox" NAME="max" VALUE="max*f=dollar12.">Largest Sale

A selection list field is provided from which the user can select a row variable. Here is the HTML code that creates the selection list:

   <SELECT NAME="row">
   <OPTION VALUE="year*month">Year and Month
   <OPTION VALUE="year">Year
   <OPTION VALUE="month">Month
   </SELECT>

These two fields along with some descriptive text and a submit button complete the form. The HTML code for this application is installed with the Dispatcher package in a default location at http://yourserver/sasweb/IntrNet8/dispatch/webtab.html.

For more detailed information about creating the input component of a Dispatcher application, see Input Component Details.

The Program Component

The Dispatcher program for this application is very simple, thanks to the Tabulate Formatter. The Tabulate Formatter works by a capture on/capture off mechanism. A macro call is made to %tab2htm before SAS code is submitted. The parameter capture=on engages the Formatter. Then SAS code is submitted and the Tabulate Formatter traps whatever would usually be sent to the output window. At the end of the program, another call to %tab2htm is made with the parameter capture=off, which disengages the Tabulate Formatter.

In addition to turning capture mode off, the Tabulate Formatter must be instructed where to send the generated HTML. Because all HTML output produced by Dispatcher programs should be sent to the fileref _WEBOUT, the parameter HTMLREF=_WEBOUT is used.

Recall, from the hello program, that each Dispatcher program must return an HTTP header followed by a null record. Here is an example.

   put 'Content-type: text/html';
   put ;

The parameter RUNMODE=S instructs the Tabulate Formatter to print the HTTP header before creating any output. If the first output produced from a Dispatcher program is created by a Formatting Tool, it is convenient to supply RUNMODE=S, allowing the Formatting tool to generate the HTTP header. However, it is important not to forget that the HTTP header must always be written either by your code or by the Formatting Tools.

To use the Tabulate Formatter in a Dispatcher program follow this general form:

   %tab2htm(capture=on);

      proc tabulate data=data set FORMCHAR='82838485868788898a8b8c'x;

      more proc tabulate statements . . .

   %tab2htm(capture=off,
         htmlfref=_webout,
         runmode=s,
         openmode=replace);

The complete code for this Dispatcher program is installed in the Application Server sample library in the file named WEBTAB.SAS.

Based on the selection that the user makes on the HTML form in this application, one of three values is passed to this program in the variable row. The macro statement %superq(row) will resolve to year*month, year, or month. Because resolution of SAS macro statements occurs before any procedures are executed, the TABULATE procedure code is resolved into the proper syntax, and the tabulation that you want is performed. In the case of a row value of year*month, one section of the procedure will require year*month and another will require year month. To do this, a new variable is created and the asterisk is translated to a space.


Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next