Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next

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 Input Component

This sample uses the HTML Data Set 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 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 a set of five 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.SHOES" checked>Shoe Sales data set<br>
<INPUT NAME="dataname<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.VOPTION">SAS Options settings<br> TYPE=radio VALUE="SAMPDAT.WEBBGT">Sample budget data set<br>
<INPUT NAME="dataname<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.VOPTION">SAS Options settings<br> TYPE=radio VALUE="SAMPDAT.WEBSALE">Sample sales data set<br>
<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.RETAIL">Retail data set<br>
<INPUT NAME="dataname" TYPE=radio VALUE="SASHELP.VOPTION">SAS Options settings<br>

The HTML code for this application is installed with the Dispatcher package in a default location of http://yourserver/sasweb/IntrNet8/dispatch/webdata1.html.


The Program Component

The SAS code to process this form is again made easy by using 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. 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 HTMLREF=. Supplying a value of _WEBOUT for this parameter directs the Formatter output to the Web browser.

The HTML form for this program offers two choices for users:

  1. The choice of table background color using an HTML selection list with a name of bgc.
  2. The choice of data set 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 you choose to display a blue background in this application, the name/value pair bgc=blue is passed. If you choose to display the retail data set, the name/value pair dataname=sashelp.retail is passed.

The complete code for this Dispatcher program is installed in the Application Server sample library in a file named webdata1.sas. When you examine this file, you will notice that there is some conditional macro code surrounding this call to %ds2htm.

Note: The above program will work, but it is insecure. Extra parameter-checking code was added to the program to provide additional security. For more information on Dispatcher security, see Application Dispatcher Security.


Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next