com.sas.servlet.tbeans.webmddbview
Class WebMDDBView

com.sas.servlet.tbeans.webmddbview.WebMDDBView
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.idesupport.ExperimentalInterface, com.sas.lang.ObjectDataInterface, RenderableInterface, TransformationInterface, com.sas.util.WriteToPrintWriterInterface, java.io.Serializable

public class WebMDDBView
implements com.sas.idesupport.ExperimentalInterface

The WEBMDDB Procedure (Experimental Procedure)

The WEBMDDB Procedure

The experimental WEBMDDB procedure reads a SAS data set, constructs a multidimensional database (MDDB) to summarize the input data, and then uses the MDDB to write out a data file. A JavaServer page (JSP) interprets the data file and displays a tabular report in a Web browser. You can design the Web report so that users can expand and drill down into report elements.

In order to produce a WEBMDDB report, you perform the following two tasks:

  1. You use PROC WEBMDDB to create the data file that encapsulates the data.
  2. You deploy a JSP that contains the logic that interprets the data file and displays the WEBMDDB report.

For information about how to perform these tasks, see the following topics:

Note: The software functions only if your site licenses SAS/MDDB® Server Software.

See also:


PROC WEBMDDB Syntax

The procedure syntax consists of the following elements:

The PROC WEBMDDB Statement

Here are the required arguments for the PROC WEBMDDB statement:

DATA=libname.memname
specifies the SAS data set that contains the data for the report.
Tip: Remember to include a LIBNAME statement to assign the libref.
OUT=fileref
specifies the fileref for the data file that is created from the procedure. You define the fileref in a FILENAME statement before you execute the WEBMDDB procedure.

Note: For information about the FILENAME statement, see "Statements" in SAS Language Reference: Dictionary.

JSP='filename.jsp'
specifies a quoted name for the JSP file that will contain the code that enables users to expand and drill down into the report. See Deploying the WEBMDDB Data File for information about the code that you need to enter into this file.

Note: See File Naming Guidelines for recommendations about how to name the SAS, JSP, and WEBMDDB files.

The PROC WEBMDDB statement has one option:

CAPTION='report-title'
specifies a 32-character maximum quoted string that is used as the title for the primary report. You can also set the CAPTION= option to '_none_'.
Default: WEBMDDB Report

The following example includes LIBNAME, FILENAME, and PROC WEBMDDB statements:


   libname sashelp 'c:\program files\sas\v8';
   filename class 'class.webmddb';
   proc webmddb data=sashelp.class out=class jsp='class.jsp' caption='Student Population Report';

 

The MEASURE Statement

The MEASURE statement defines the columns that are summarized in the report. For each MEASURE statement, you specify one variable and one statistic using the form variable_statistic. For example, to derive the sum of a variable named amount, you specify amount_sum. The available statistics are N, SUM, AVG, NMISS, SUMWGT, MIN, MAX, USS, UWSUM, RANGE, CSS, VAR, STD, STDERR, CV, T, PRT, LCLM, UCLM, PCTSUM, and PCTN.

Note: For more information about the statistics, see "SAS Elementary Statistics Procedures" in Base SAS Procedures Guide.

The MEASURE statement has the following options:

FORMAT=
specifies a SAS or user-defined format in the form format<w>.<d> that is applied to the measure value. For example, in FORMAT=DOLLAR10.2, the w value of 10 specifies a maximum of 10 columns for the value. The d value of 2 specifies that two of these columns are for the decimal part of the value, which leaves eight columns for all the remaining characters in the value. This includes the decimal point, the remaining numeric value, a minus sign if the value is negative, the dollar sign, and commas, if any.

Note: For more information about SAS formats, see "Formats" in SAS Language Reference: Concepts.

PRECISION=numeric-value
specifies the total width of the value that is displayed, including commas, decimal points, and signs.
SCALE=numeric-value
specifies the number of decimal places that are displayed.
WEIGHT=variable-name
for weighted statistics, this option specifies the name of the variable that is used in the calculations.
Requirement: This option is required for weighted statistics.
CAPTION='column-header'
specifies a 32-character maximum quoted string that is displayed in the table as the column header for the measure.
Default: The variable name plus the statistic name. For example, if the variable is named amount and the statistic is SUM, then the default column header is AMOUNT SUM.

If you do not specify a format (using either FORMAT=, PRECISION=, or SCALE=), PROC WEBMDDB applies a format to the measure according to the following rules:

Insert a forward slash / before listing the options. The following MEASURE statement example uses FORMAT= and CAPTION= options.

       measure weight_avg / format=COMMA8.4 caption='Avg Weight';
 

The DIMENSION Statement

The DIMENSION statement lists the classification variables that are displayed in the report. This statement also sets the drill-down hierarchy for the table in the primary report; for this reason, you must order the classification variables to follow a logical drill-down path into the MDDB. The first classification variable listed is the top level in the table and the subsequent classification variables are the lower levels.

The JSP file includes code that enables users to click each classification variable in the table to display the values of the next variable. When the user reaches the lowest classification variable in the dimension, the detail report is displayed in a new browser window. (See The DETAIL Statement for information about how to specify what information is included in the detail report.)

Note: You can have only one DIMENSION statement per WEBMDDB report.

By default, all classification variables are sorted in ascending order. To specify a different order, enter one of the following keywords after you specify the classification variable name:

In the following example, the classification variable age is sorted in descending order, and the classification variable sex uses the default ascending order.

      dimension age descending sex / caption='Age .. Sex';
 

The DIMENSION statement has one option:

/ CAPTION='column-header'
specifies a 32-character maximum quoted string that is displayed in the table as the column header for the dimension column.
Default: Column header is left blank.

The DETAIL Statement

The DETAIL statement lists the variables in the input data set that are displayed in a detail report after you click on the lowest classification variable in the dimension. The detail report, which opens in a separate browser window, displays data for the items that make up one row of the lowest level in the dimension. Variable labels from the input data set are used as column headers.

For example, you could create a primary report that shows sales prospects by region, category, and product. A manager could expand the report down to the product classification variable in the school supplies category of the western region. He could then select the product link in the table to display a list of customers who are interested in notebooks and organizers in that area.

The DETAIL statement has one option:

/ CAPTION='report-title'
specifies a 32-character maximum quoted string that is displayed as the title for the detail table. You can also set the CAPTION= option to '_none_'.
Default: WEBMDDB Detail Report
The following code is an example of a DETAIL statement:
     detail age sex name height weight / caption='Population Detail Report';
 

PROC WEBMDDB Sample Code

The following PROC WEBMDDB example code builds a report from a data set named SASHELP.CLASS.

      libname sashelp 'c:\program files\sas\v8';
      filename class 'class.webmddb';

      proc webmddb data=sashelp.class out=class jsp='class.jsp' caption='Student Population Report';

        measure height_min / caption='Min Height';
        measure height_avg / caption='Avg Height';
        measure height_max / caption='Max Height';

        measure weight_min / caption='Min Weight';
        measure weight_avg / caption='Avg Weight';
        measure weight_max / caption='Max Weight';

        dimension age sex  / caption='Age .. Sex';

        detail age sex name height weight / caption='Population Detail Report';
   run;
 

Deploying the WEBMDDB Data File

Each WEBMDDB report requires an associated JSP file. The JSP file contains the code that enables users to expand and drill down into the report. You name the file with the JSP= argument on the PROC WEBMDDB statement.

Cut and paste the following sample code into your JSP file. To customize the file for your report, change the following items:

This sample assumes that the class.webmddb data file is stored in d:\inetpub\wwwroot\webmddb\. To accommodate Java programming conventions, double backslashes are used in the directory path.

 <jsp:useBean id="classExView"
   class="com.sas.servlet.tbeans.webmddbview.WebMDDBView"
    scope="session">

 <jsp:setProperty name="classExView" property="fileName"
     value="d:\\inetpub\\wwwroot\\WEBMDDB\\class.webmddb" />

 <jsp:setProperty name="classExView" property="styleClass"
     value="wTable" />

 </jsp:useBean>

 <html>
 <head>
 <LINK REL=STYLESHEET HREF="sasComponents.css" TYPE="text/css">
 </head>

 <body>

 <H5>EXAMPLE</H5>
 <BR><BR>

 <%
    classExView.processCommand(request);
    classExView.write(out);
 %>

 <BR><BR><BR>

 </body>
 </html>
 

Also, add any other HTML content that you want to appear in the report.

Note: Refer to your application server software documentation for information about how to deploy JSPs for testing and for production.


File Naming Guidelines

Give the same name to the three files that are used to create the WEBMDDB report. The three files are:

Within the JSP file, you also rename the session object for the WEBMDDB report so that it corresponds with your filenames (see Deploying the WEBMDDB Data File).

For example, if you name your SAS program foo.sas, then name your WEBMDDB file foo.webmddb, and name your JSP file foo.jsp. Within the JSP file, change all session object references to fooExView.


Customizing the Appearance of a WEBMDDB Report

The appearance of the WEBMDDB report is controlled by a cascading style sheet (CSS). To change the default style settings, you edit the CSS (using a text editor, for example). The CSS includes the following style classes:

wTable
controls the appearance of the primary and detail tables. You can specify border width, border color, background images, background colors, and the spacing of the data in the table cells.
wColLab
controls the appearance of the column labels for the primary report table. All column labels use this element. You can set background colors, font colors, and sizes.
wRowLab
controls the appearance of the data row labels. The label is the first item in each row.
wDrillColLab
controls the appearance of the column headings for the detail table.
wDrillRowLab
controls the appearance of the data row labels in the detail table. The label is the first item in each row.
wTitle
controls the appearance of the title of the primary report.
wSubTitle
controls the appearance of the title of the detail table.
wTotLab
controls the appearance of the label for the total row in the primary report. The label is the first item in the total row.
wTotData
controls the appearance of the data displayed in the total row, which is the last row in the primary table.

Receiving Support

The WEBMDDB procedure is not supported by SAS Institute Technical Support.


Note that the toString() method on this class calls the write method, which may have undesirable side effects. See BaseTransformation.toString() for more information. Debuggers often use toString() to show the value of a variable, and this may cause unexpected behavior while debugging

See Also:
Serialized Form

Field Summary
static int COLLAPSE_COMMAND
          Returned by process command method when a collapse command is being processed
static int EXPAND_COMMAND
          Returned by process command method when a expand command is being processed
static int NULL_COMMAND
          Returned by process command method when a no command information could be processed.
static java.lang.String RB_KEY
           
static int SHOW_DETAIL_DATA_COMMAND
          Returned by process command method when a show detail command is being processed
 
Constructor Summary
WebMDDBView()
          Default Constructor
WebMDDBView(java.lang.String name)
          Constructor
 
Method Summary
 java.lang.String getFileName()
          Returns the name of the text file to read.
 int processCommand(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Processes the parameters found on the request object.
 int processCommand(javax.servlet.jsp.PageContext pageContext)
          Processes the parameters found on the request object.
 void setFileName(java.lang.String fname)
          Sets the name of the text file to be read
 void setFileName(java.lang.String fname, javax.servlet.jsp.PageContext pc)
          Sets the name of the text file to be read.
 void setFileName(java.lang.String fname, javax.servlet.ServletContext sc)
          Sets the name of the text file to be read.
 void write(java.io.PrintWriter out)
          Writes the content to the PrintWriter object.
 
Methods inherited from class com.sas.servlet.tbeans.BaseTransformation
addPropertyChangeListener, addPropertyChangeListener, cleanUpResources, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCustomAttributes, getDescription, getId, getInputTransform, getLocale, getName, getObjectData, getObjectDataProperty, getOutputTransform, getRequest, getResponse, getTagEpilog, getTagProlog, hasListeners, isCleanUpResourcesOn, isVisible, removePropertyChangeListener, removePropertyChangeListener, setCleanUpResourcesOn, setCustomAttributes, setDescription, setId, setInputTransform, setLocale, setLocaleDependentProperties, setName, setObjectData, setObjectDataProperty, setOutputTransform, setRequest, setResponse, setTagEpilog, setTagProlog, setVisible, toString, write, write, write
 

Field Detail

NULL_COMMAND

public static final int NULL_COMMAND
Returned by process command method when a no command information could be processed.

See Also:
Constant Field Values

EXPAND_COMMAND

public static final int EXPAND_COMMAND
Returned by process command method when a expand command is being processed

See Also:
Constant Field Values

COLLAPSE_COMMAND

public static final int COLLAPSE_COMMAND
Returned by process command method when a collapse command is being processed

See Also:
Constant Field Values

SHOW_DETAIL_DATA_COMMAND

public static final int SHOW_DETAIL_DATA_COMMAND
Returned by process command method when a show detail command is being processed

See Also:
Constant Field Values

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

WebMDDBView

public WebMDDBView()
Default Constructor


WebMDDBView

public WebMDDBView(java.lang.String name)
Constructor

Parameters:
name - the name of the object.
Method Detail

write

public void write(java.io.PrintWriter out)
           throws java.io.IOException
Writes the content to the PrintWriter object.

Specified by:
write in interface TransformationInterface
Specified by:
write in interface com.sas.util.WriteToPrintWriterInterface
Overrides:
write in class BaseTransformation
Parameters:
out - java.io.PrintWriter object
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

getFileName

public java.lang.String getFileName()
Returns the name of the text file to read.

Returns:
name of the text file to be read.

setFileName

public void setFileName(java.lang.String fname)
                 throws java.io.IOException
Sets the name of the text file to be read.\

Parameters:
fname - name of the text file.
Throws:
java.io.IOException

setFileName

public void setFileName(java.lang.String fname,
                        javax.servlet.jsp.PageContext pc)
                 throws java.io.IOException
Sets the name of the text file to be read. This is a convenience method for jsp page users and allows the file name to use a virtual path for the file. The true path for the file will be resolved by the method.

Parameters:
fname - virtual path for the file
pc - PageContext object
Throws:
java.io.IOException

setFileName

public void setFileName(java.lang.String fname,
                        javax.servlet.ServletContext sc)
                 throws java.io.IOException
Sets the name of the text file to be read. This is a convenience method for servlet users and allows the file name to use a virtual path for the file. The true path for the file will be resolved by the method.

Parameters:
fname - virtual path for the file
pc - PageContext object
Throws:
java.io.IOException

processCommand

public int processCommand(javax.servlet.jsp.PageContext pageContext)
                   throws java.io.IOException
Processes the parameters found on the request object. This form of the processCommand method should be used writing JSP Pages. If you are writing a servlet use processCommand(HttpServletRequest req, HttpServletResponse resp).

Parameters:
pageContext - javax.servlet.jsp.PageContext object
Returns:
ExpandableReportViewer.COLLAPSE_COMMAND, ExpandableReportViewer.EXPAND_COMMAND, ExpandableReportViewer.SHOW_DETAIL_DATA_COMMAND.
Throws:
java.io.IOException

processCommand

public int processCommand(javax.servlet.http.HttpServletRequest req,
                          javax.servlet.http.HttpServletResponse resp)
                   throws java.io.IOException
Processes the parameters found on the request object. This form of the method should be used when writing a servlet.

Parameters:
req - HttpServletRequest object
resp - HttpServletRepsonse object
Returns:
ExpandableReportViewer.COLLAPSE_COMMAND, ExpandableReportViewer.EXPAND_COMMAND, ExpandableReportViewer.EXPORT_TO_EXCEL_COMMAND, or SHOW_DETAIL_DATA_COMMAND
Throws:
java.io.IOException



Copyright © 2009 SAS Institute Inc. All Rights Reserved.