SAS/IntrNet 1.2: Application Dispatcher |
Creating Dispatcher Applications - Display a Data Set with Where Clause and Sum VariablesThe HTML PageThis application is very similar to the previous application which displays a data set. One important difference is the feature that allows the user to select one or more years' worth of data to display. This selection subsets the data in the resulting output. Allowing users to subset the displayed data makes an application much more useful. Two other options are available via checkboxes on the form. The user can select to display a total by sales and/or select to display observation numbers. A selection list of years is created with the following HTML code: <SELECT NAME="year" MULTIPLE> <OPTION VALUE="1981"> 1981 <OPTION VALUE="1990"> 1990 <OPTION VALUE="1991"> 1991 <OPTION VALUE="1992"> 1992 <OPTION VALUE="1993"> 1993 <OPTION VALUE="1994"> 1994 </SELECT> This is slightly different from the previous selection lists because it allows the user to select more than one value from the list. The keyword The two check boxes are created with the following HTML code: <INPUT TYPE="checkbox" NAME="sumvar" VALUE="sales" CHECKED>Total by Sales <INPUT TYPE="checkbox" NAME="observ" VALUE="yes">Display Observation numbers There are special concerns with handling multiple selection lists and check boxes in a Dispatcher program. The Dispatch Program section of this page will address them. The entire HTML code for this application is contained in the the Broker package sample directory in a file named dataset2.html. The code produces a form that looks like this: Two new selection lists have been added to the bottom of this form. Previously, the special Dispatcher variable By examining the "Debugging level" list, you can
see that The Dispatcher ProgramNo changes need to be made in the Dispatcher program to incorporate the new selection lists for service and debug. The service value is treated the same by the Dispatcher whether it is a hidden field or not. The value of The first hurdle that this application presents are the check boxes. Check boxes were used before in the tabulate sample but were not explained. If a check box such as the observation numbers box is selected on the form, then a name/value pair such as %global sumvar observ year0; The global declaration will not clear or reset any values contained in these variables, it will simply make sure that these macro variables exist and are global in scope. If values were not passed, then these variables will be blank. The next task this Dispatcher program must perform is creating a WHERE clause to subset the rows in the data set. Recall the selection list of years that allows multiple selections. If the user chose "1991", the name/value pair If the user chooses "1981", "1991", and "1993", the Dispatcher receives the following three name/value pairs
At first this looks like it might cause a problem because one name is used for three values. However, the Dispatcher handles multiple values in a special way. These three name/value pairs will actually produce the following macro variables in the SAS session.
The Dispatcher has used a number suffix to produce unique variable names. This feature allows programs to accept and process multiple name/value pairs. The details of how multiple values are created and handled by the Application Dispatcher are explained more fully in Understanding Name/Value Pairs. Now, a WHERE clause can be generated for an arbitrary number of years. Because the variable /* This macro code will build a WHERE clause */ %macro genwhr; %local i or; %global year year0; %if %length(%superq(year)) gt 0 %then %if %superq(year0) = %then %let year0=1; %let year1 = %superq(year); %do i = 1 %to %superq(year0); %let whrcls=&whrcls &or (year=%superq(year&i)); %let or = or; %end; %end; %mend; This code accounts for the possibility that zero years may be selected, that only one year may be selected, and that multiple years may be selected. It is essential to realize that the Next, notice the check for Read the other example application sections to learn more or jump right to the details about the program component in Dispatcher Program Details. |
SAS/IntrNet 1.2: Application Dispatcher |