Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next
 

Creating Dispatcher Applications - Display a Data Set

This application illustrates how to display the data from a SAS data set and offer the user some simple customization options.


The HTML Page

This example uses the HTML Data Set Formatter, one of the HTML Formatting Tools provided by SAS, to create an HTML-formatted table. This tool will produce all of the HTML output for this application!

The form for this sample application contains a selection list and radio buttons, which allow the user some control over the output.

The selection list lets the user choose a background color for the table. Notice that you can pass color values by specifying the color name or the Red, Green, Blue (RGB) value.

<SELECT NAME= "bgc"> 
<OPTION VALUE="blue" > Blue 
<OPTION VALUE="c0c0c0" SELECTED > Gray 
<OPTION VALUE="teal"> Teal 
</SELECT> 

Another field type that allows users to choose from a set of values is the radio button. This page contains two radio buttons that are used to choose a data set to be displayed. Radio buttons are created by using the INPUT tag with a type of RADIO.

<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.RETAIL" checked>Retail data set<br>
<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.VOPTION">SAS Options settings<br>

The entire HTML code for this application is contained in the the Broker package sample directory in a file named dataset1.html. The code produces a form that looks like this:

display a data set

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


The Dispatcher Program

The SAS code to process this form is again made easy by using the a Formatting Tool. The HTML Data Set Formatter and the other HTML Formatting Tools can be used in Dispatcher programs, providing power and flexibility while saving you a lot of programming effort.

The Data Set Formatter is invoked by calling the macro %ds2htm and supplying it with a set of parameters. Here is the source code for this Dispatcher program:

      %ds2htm(data=%superq(dataname),
          runmode=s,
          openmode=replace,
          htmlfref=_WEBOUT,
          bgtype=color,
          bg=white,
          tbbgcolr=%superq(bgc),
          bwidth=5,
          encode=n,
          caption=Dataset %superq(dataname)  brought to you by the Data Set
                  Formatter,
          ccolor=blue,
          ctag=header 3,
          center=y,
          clbgcolr=silver,
          septype=none,
          brtitle=First Sample Data Set Formatter Program);

The parameter runmode=s instructs the Data Set Formatter to print the required HTTP header before creating any output. Again, we could have used a DATA step to do this, but the runmode parameter is more convenient.

Another requirement of all Dispatcher programs is to make sure that the output is directed to the fileref _WEBOUT. The Formatting Tools accept the parameter htmlfref=. Supplying a value of _WEBOUT for this parameter directs the Formatter output to the Web browser.

The HTML form for this program offered two choices for users. The choice of table background color was made using an HTML selection list with a name of bgc. The choice of data set was made using a set of radio buttons with a name of dataname. When the submit button is pressed on the form, the browser passes the name/value pairs as NAME=VALUE to the Broker. For example, if the user chose to display a blue background in this application, the name/value pair bgc=blue is passed. If the user chose to display the retail data set, the name/value pair dataname=sashelp.retail is passed.

The Broker in turn passes the name/value pairs to the Application Server. The Application Server takes the name/value pairs and creates SAS macro variables for use in the Dispatcher program. In the source code for this program, the values are retrieved using the %superq() macro function.

The background color selected on the page is passed to the Data Set Formatter in the tbbgcolr= parameter, and the data set name is passed in the data= parameter. The complete source code for this program is contained in the Application Server package sample directory in a file named dataset1.sas. When you examine this file, you will notice that there is some conditional macro code surrounding this call to %ds2htm. The above program will work just fine, but it is insecure. Extra parameter checking code was added to the program in your package for security reasons. For more information on Dispatcher security, see the Security section. Read the other example application sections to learn more, or jump right to the details about the program component in Dispatcher Program Details.


Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next