This post describes using a SAS Server Page to present the user with the available choices. Try out this sample SAS Server Page based UI by clicking on either of the following links:
- Using the Stored Process Server:
http://demos.hcsbi.com:8080/SASStoredProcess/guest?_program=/GuestDemos/sasServerPage&page=PieChartUI - Using the SAS/IntrNet Application Dispatcher:
http://demos.hcsbi.com/scripts/broker.exe?_service=ssp&_program=sspebook.sasServerPage.sas&page=PieChartUI
Assign a default for the data set to use. The data set could be selected in a prior page. To keep this example simple, a different data set can be specified by adding data to the URL as a name/value pair. The %sysfunc macro function uses the COALESCEC function to assign a default value. The macro variables lib and mem are used later in the page.
%global data;
%let data = %sysfunc(coalescec(&data,sashelp.shoes));
%let lib = %upcase(%scan(&data,1));
%let mem = %upcase(%scan(&data,2));
The initial HTML tags.
<html>
<head>
<title>UI for PieChart SSP Example</title>
</head>
When the page is initially loaded, submit the form with the default values.
<body onLoad="document.forms[0].submit();">
The FORM tag specifies that the output is displayed in another part of the page. It also uses the macro variable, _URL. This macro variable is created by the server and using this parameter is a sugggested Best Practice. Using _URL also allows for the same SAS Server Page to be processed by the both the Stored Process Server as well as the SAS/IntrNet Application Dispatcher.
<form action="&_url" target="results">
A standard header is defined by using %INCLUDE to dynamically include another input SAS Server Page. Using %INCLUDE ensures consistency and allows for easy updates/maintenance.
&streamDelim;%include srvrpgs(standardHeader.html);
Use an HTML table to arrange the select tags along the top of the page.
<table border="0">
Use the server created macro variable _program - both this UI and the PieChart SAS Server Page use the sasServerPage program. Using &_program is another Best Practice.
<input type="hidden" name="_program" value="&_program">
<input type="hidden" name="page" value="PieChart">
<input type="hidden" name="data" value="&data">
Use the generateOptionTag macro (a topic for a future posting), to create a select tag from data in a SAS Data Set. In this case, the data set is one that was created by a program that queried the provided SAS Styles to extract the color schemes.
<tr>
<td>ODS Color Pattern:
<td>%generateOptionTag
(data=parms.colorList
,var=colorlist
,name=colors
,label=Style
)
Use the generateOptionTag macro using the DATA step views of the dictionary tables. In this case the slice variables are limited to character variables (not a good approach in general - but done here for the sake of simplicity).
<td>Slice Variable:
<td>%generateOptionTag
(data=sashelp.vcolumn
,var=name
,name=class
,selected=Product
,where=libname="&lib"
and memname="&mem"
and type="char"
)
Use the generateOptionTag macro again, this time including numeric variables.
lt;td>Analysis Variable:
<td>%generateOptionTag
(data=sashelp.vcolumn
,var=name
,name=var
,selected=Sales
,where=libname="&lib"
and memname="&mem"
and type="num"
)
A hard-coded select tag for the statistic to use.
<td>Statistic:
<td>@select name="statistic">
@option>Sum
@option>Mean
@option>Min
@option>Max
</select>
The submit button and close the form.
<td>@input type="submit" value="Run">
<form>
</tr>
</table>
An iframe tag is used the embed the output into the same page as the UI. Note that the value of the name parameter matches the target value from the form tag.
<iframe name="results"
width="100%"
height="100%"
frameborder="0">
</iframe>
Close the HTML page.
</body>
</html>
No comments:
Post a Comment