Controlling Drill-Down Behavior for ActiveX and Java Using Parameters

Using ODS Parameter Tags

You can use parameter tags in the ODS HTML statement to specify drill-down behavior for the ActiveX control, the Graph applet, or the Map applet, in the ODS HTML statement. Parameters are specified in the ODS destination statement with the PARAMETERS= option as follows:
ODS HTML PARAMETERS=(options);
See Attributes and Parameters for Java and ActiveX for a detailed description of the parameter tags and attributes that are available for use with ActiveX and Java.

Using Drill-Down Tags

You can use the following tags to specify drill-down behavior for the Graph applet, Map applet, or ActiveX control. The following table defines the drill-down tags and explains the types of graphs to which the tags can be applied.
Drill-Down Tags Used by the Graph Applet, Map Applet, and ActiveX Control
Tag Name
Description
Definition of the Value That Follows the Tag
Applied in
G_COLOR
Use new colors for the graph elements
Name of the new color variable
Scatter plots
G_COLORV
Use the color variable from the preceding level
None
Scatter plots
G_DEP
Use a new dependent variable
Name of the new dependent variable
All charts
G_DEPV
Use the dependent variable from the previous level
None
All charts
G_DEPTH
Use a new depth variable
Name of the new depth variable
Vertical bar charts and scatter plots
G_DEPTHV
Use the depth variable that was used in the previous level
None
Vertical bar charts and scatter plots
G_GROUP
Use a new group variable
Name of the new group variable
Bar charts
G_GROUPV
Use the group variable that was used in the previous level
None
Bar charts
G_INDEP
Use a new independent variable
Name of the new independent variable
Charts and maps
G_INDEPV
Use the independent variable that was used in the previous level
None
Charts and maps
G_LABEL
Use a new label
Name of the new label (mapID) variable
Maps
G_LABELV
Use the same label that was used in the previous level
None
Maps
G_SUBGR
Use a new subgroup variable
Name of the new subgroup variable
Bar charts and scatter plots
G_SUBGRV
Use the same subgroup variable that was used in the previous level
None
Bar charts and scatter plots
When you specify a variable name after a tag, the name must be specified exactly the way it appears in the data set. Variable names are case-sensitive in JavaScript. To find out how a variable was defined in the data set, use the CONTENTS procedure.

Specifying the Drill-Down Mode

To enable a given drill-down mode, specify a value for the parameter DRILLDOWNMODE. The DRILLDOWNMODE parameter is specified in an ODS statement. The following syntax sets the DRILLDOWNMODE parameter in the ODS statement:
ODS HTML PARAMETERS= (“DRILLDOWNMODE”=
“LOCAL”|“SCRIPT”|“URL”|“HTML”);
Local mode
responds to drill-down actions by dynamically generating and displaying new graphs. The data in the initial graph is subset based on the graph element that was selected in the drill-down action. The user can select another graph element to generate another graph. Another graph is generated as long as the data can still be subset, or you have configured your own levels of drill-down.
To configure a graph at a given level, you specify the applet parameter DDLEVELn. The value of this parameter determines the graph type, data subset, variable roles, and colors. Local is the default drill-down mode for the Graph applet.
Restriction:Supported by the Graph applet only.
Script mode
calls a JavaScript method that you specify in your SAS/GRAPH program. You provide the JavaScript that responds to the selected area. The data passed to the JavaScript method determines the graphic portion selected, and the appropriate action.
URL mode
displays URLs that are provided by the HTML= variable. The URLs identify HTML files.
Restriction:If the graphics procedure that generates the graph specifies the HTML= option, then the value of the DRILLDOWNMODE parameter is automatically set to URL. All modes specified in ODS are overridden.
See:HTML
HTML mode
generates drill-down URLs based on a substitution pattern that you specify in your SAS/GRAPH program. The ActiveX control, the Graph applet, and the Map applet complete the URL by inserting the specified data from the selected graph element.
ods html file=statepop.htm
   parameters=("DRILLDOWNMODE"="HTML"
   "DRILLPATTERN"="http://www.state.{&statename}.us");
The data set variable value STATENAME completes the drill-down URL.
Note:Define the variable with the partial URL when creating the graphic.
Any mode
attempts to implement the four drill-down modes in succession until a valid Web destination is found. The order is Local (Graph applet only), Script, URL, and HTML.
Restriction:Supported by Graph applet and ActiveX control only.
See:Specifying Parameters and Attributes for Java and ActiveX for a complete list of ODS parameters.

Understanding Variable Roles

The assignment of roles to variables determines the appearance of the resulting graph. The assignment of roles takes place in the SAS/GRAPH statement that generates the graph. One variable is always assigned the role of independent variable, and another is always assigned the role of dependent variable. Once the initial graph has been displayed in the applet or control, Web users can change the variable roles using menu options.
Variable roles are used to configure the Local, HTML, and Script drill-down modes. The roles are assigned with parameters, using the PARAMETERS= option in the ODS statement. In the specification of a parameter, the assignment of roles is done with drill-down tags.

Removing Blank Spaces from Data Values in Substitution Strings

The drill-down modes Script (see Configuring Script Drill-Down Mode) and HTML (see Configuring the Drill-Down Response in HTML and URL Modes) make use of substitution strings to generate a response to drill-down actions. The substitution strings are replaced with data values. Blank spaces in those data values can produce unexpected results. To remove blank spaces from data values when those values are to be used in a substitution string, specify the PATTERNSTRIP parameter as follows in the ODS statement:
ODS HTML FILE=fileref-or-external-file
PARAMETERS=(“DRILLDOWNMODE”=“SCRIPT | URL”
“PATTERNSTRIP”=“NONE | YES | COMPRESS”);
NONE
is the default value. Any blank spaces in the data value are inserted into the substitution string.
YES
removes all blank spaces from the end of the data value, but retains blank spaces elsewhere.
COMPRESS
removes all blank spaces from the data value, wherever they occur.

Using Variables as Substitution Strings

When you specify a variable name as a substitution string in the HTML drill-down mode, the applet or control replaces the entire string with the value of the variable as it is specified in the selected graph element. The syntax of the substitution string is as follows:
{&variable_name}
Because JavaScript is case sensitive, the name of the variable must be exactly the same as it is in the data set.
A variable name substitution string might look like this:
http://ourweb.com/uspop/{&statename}/poptable.htm
The substitution string above could be used in a Web presentation that begins with a map of the United States. In response to a drill-down action in HTML mode, the value of the STATENAME variable for the selected state would be substituted into the URL. The resulting URL would point to a Web page that contains a table of population information for the selected state.
In the HTML drill-down mode, you can specify variable roles or labels as substitution strings, using drill-down tags, as described in Understanding Variable Roles. The syntax of these substitution strings is as follows:
{&drill-down-tag}
where drill-down-tag specifies a variable role or label in the initial graph. The applet or control replaces the substitution string by deriving a variable name from the role or label, and applying the value of that variable to the URL. The value is taken from the data that is associated with the selected graph element.
For example, a Web presentation could be configured using this URL:
http://ourweb.com/regstaff/{&G_INDEPV}/stafflist.htm.
When a Web user selects a data element with the independent variable REGION, if the value of REGION is East, the applet displays this URL:
http://ourweb.com/regstaff/East/stafflist.htm.
The default value for the DRILLPATTERN parameter is as follows:
{&G_INDEPV,f}{&G_GROUPV,f}{&G_SUBGRV,f}.html
The URL that is created points to an HTML file that is in the same directory as the top level HTML file. The name of the file is a concatenation of formatted values for the first independent, group, and subgroup variables defined in the data set.
See Example: URL Drill-Down Mode with Java for more information.

Configuring HTML Drill-Down Mode

Using the DRILLDOWNMODE, DRILLPATTERN, PATTERNSTRIP, and DRILLTARGET Parameters

You can use the parameters DRILLDOWNMODE, DRILLPATTERN, PATTERNSTRIP, and DRILLTARGET to configure the HTML drill-down mode for the ActiveX control, the Graph applet, and the Map applet.
In the HTML drill-down mode, the applet or control responds to drill-down actions by constructing a uniform resource locator (URL) using the data in the selected graph element. The URL is passed to the Web browser for display.
The parameter DRILLDOWNMODE (see Parameter Reference for Java and ActiveX) establishes the HTML drill-down mode. The PATTERNSTRIP parameter (see Removing Blank Spaces from Data Values in Substitution Strings) can be used to selectively remove blank spaces from data values before those values are applied to the URL. The DRILLTARGET parameter (see Using Variables as Substitution Strings) enables you to specify where you want the drill-down graph to appear in the browser.
Specify the DRILLPATTERN parameter in the ODS statement:
ODS HTML
PARAMETERS=(“DRILLDOWNMODE”=“HTML”
“DRILLPATTERN”=“URL-with-substitution-strings”);
An example of this statement might look like this:
ods html file=statepop.htm
   parameters=("DRILLDOWNMODE"="HTML"
      "DRILLPATTERN"="http://www.state.{&statename}.us");
In this example, the value of the data set variable STATENAME completes the drill-down URL.
When ODS is configured as shown above, the applet or control dynamically generates URLs in response to drill-down actions. The applet or control replaces the substitution strings with data values from the graph element that was selected in the drill-down action. The URL-with-substitution-strings value can include multiple substitution strings. Substitution strings can include combinations of variable names, variable roles or labels, and drill-down tags. For details, see Using Variables as Substitution Strings. All substitution strings are enclosed in curly brackets ( { and } )  and begin with an ampersand character (&).
If a variable name is specified as a substitution string in drill-down mode; the applet and the control replace the string with the value of the selected data item.

Specifying Graphs for Each Drill-Down Level

The DDLEVELn parameter lets you specify the graphs that are generated at each drill-down level.
Note: The ActiveX Control does not support the DDLEVELn parameter.
The DDLEVELn parameter is specified as follows in the ODS statement:
ODS HTML
PARAMETERS=(“DDLEVELn”=“string”);
n
represents the number of the drill-down level that is being configured.
string
  • specifies the graph type.
  • names the variable roles.
  • specifies the color of the data elements.
  • names the variable to subset, to create the next graph.
The syntax of the string argument is as follows:
{CHART} {chart_type} {tag_1} {variable_1...} {...tag_n} {variable_n} |
{subset_tag_1...} <{...subset_tag_n}>
{CHART} {chart_type}
identifies the type or style of the graph. This tag is case sensitive: it must always be specified in uppercase. The values of the tag (chart types) are not case sensitive. To use the same chart type as the preceding drill-down level, do not specify the CHART tag. When the {CHART}{chart_type} is specified in the DDLEVELn parameter, the chart type can be completely changed, but not the chart orientation. For example:
  • a vertical or horizontal bar chart can be changed to a pie chart
  • a horizontal bar chart cannot be changed to a vertical bar char
  • vertical bar chart cannot be changed to a horizontal bar chart
Available chart types are as follows:
BAR
generates a two-dimensional bar chart.
BAR3D
generates a three-dimensional bar chart.
PIE
generates a two-dimensional pie chart.
PIE3D
generates a three-dimensional pie chart.
PLOT
generates a two-dimensional scatter plot that is similar in appearance to the plot shown in Scatter Plots.
SCATTER
generates a scatter plot that is similar in appearance to the plot shown in Generating a Scatter Plot.
LINE
generates a line or needle plot that is similar in appearance to Needle Plot.
BOX
generates a box plot that is similar in appearance to Box Plot.
HILO
generates a high-low chart that is similar in appearance to High-Low Plot.
For BAR and BAR3D charts, the orientation from the previous chart is used. If the previous chart does not have an orientation, the vertical orientation is used by default.
{tag_1} {variable_1...} {...tag_n} {variable_n}
associates drill-down tags with data set variables, to specify roles for variables in the new graph, and to determine the color of the elements in the new graph (optional). For definitions of the drill-down tags, see Parameters Enabled for Java and ActiveX.
{subset_tag_1...} <{...subset_tag_n}>
specifies one or more variable roles from the original graph whose values are used to subset the data in the preceding graph. If you specify G_GROUPV, then the data that is used to draw the new graph, is only the data that is associated with the group variable in the preceding graph. If the group variable in the preceding graph is REGION, and the data element labeled East is selected, only observations where REGION=EAST are represented in the next graph.
At least one of the following tags must be specified as the subset variable: G_INDEPV, G_GROUPV, G_SUBGRV, or G_DEPTHV. For definitions of these tags, see Parameters Enabled for Java and ActiveX.
Specifying multiple subset variables means that two or more values must match the value in the selected graph element for that observation to be used in the new graph. For example, assuming that you specify {G_INDEPV}{G_SUBGRV} as the subset variables, and that the selected graph element has an independent variable of YEAR and a subgroup variable of STATE. Also assume that the values for these variables in the selected graph element were 2000 and NC. The observations that would be used in the drill-down graph would include those with YEAR=2000 and STATE=NC.
The following example shows how the DDLEVENn parameter can be used to specify the default behavior for the first drill-down level.
ods html file=odsout
  parameters=("drilldownmode"="local"
        "ddlevel1"="{chart}{vbar3d}
              {g_dep}{sales}
              {g_indep}{year} |
              {g_indepv}" );
As the example shows, the value of the DDLEVELn parameter is divided into two halves, which are separated by a vertical bar character. The drill-down graph is configured in the syntax that appears before the vertical bar character ( | ). After the vertical bar, drill-down tags specify how the data from the previous drill-down level is to be subset for use in the current drill-down graph.
The first drill-down level (DDLEVEL1) is configured as a three-dimensional vertical bar chart. The dependent variable is SALES and the independent variable is YEAR. The G_INDEPV tag specifies that the data is to be based on the values of the independent variable. In our example the independent variable in the initial graph is REGION. If the Web user selects a graph element that describes the WEST region, the graph has only observations where the value of REGION is WEST.
If you do not specify a role for a variable, then that variable does not appear in the drill-down graph. If you do not specify variables for the G_DEP and G_INDEP tags, then the Graph applet uses the independent and dependent variables of the graph in the preceding drill-down level.
You can explicitly remove a variable role from the drill-down graph by specifying a $ character as the drill-down value, as in the following code:
{G_GROUP} {$}
Web users can make this change in the Graph applet menus by selecting the None option from the list of variables that can be applied to a given variable role.
Note: Note that you cannot assign a $ to the G_INDEP and G_DEP variables, because they must always be present in the drill-down graph.

Configuring the Drill-Down Response in HTML and URL Modes

In the HTML and URL drill-down modes, you can specify the parameter DRILLTARGET to specify where you want the Web browser to display drill-down graphs. By default, the applet or control displays drill-down graphs in a new Web browser window.
Specify the DRILLTARGET parameter as follows, using the PARAMETERS= option in the ODS statement:
ODS HTML
PARAMETERS=(“DRILLTARGET”=
“_BLANK” | “_SELF” | “_PARENT” | “_TOP” | any_named_target)
_BLANK
displays the drill-down graph in a newly opened, unnamed browser window.
_SELF
displays the drill-down graph in the same frame or window as the initial graph. This is the default behavior in most browsers.
_PARENT
displays the drill-down graph in the parent frame in a frame set. If no frames are defined, this value is the same as _SELF.
_TOP
displays the drill-down graph in the full browser window, thereby replacing any frames that were defined in that window.
any_named_target
displays the drill-down graph in the appropriately named frame or browser window.

Configuring Script Drill-Down Mode

Using the DRILLDOWNMODE, DRILLFUNC,  PATTERNSTRIP, and DRILLTARGET Parameters

You can use the parameters DRILLDOWNMODE, DRILLFUNC,  PATTERNSTRIP, and DRILLTARGET to configure the Script drill-down mode for the ActiveX control, the Graph applet, and the Map applet. The Script drill-down mode enables you to execute a JavaScript callback method in response to drill-down actions. You use PUT statements to write the callback method into the HTML output file. Some experience with JavaScript is therefore required.
The syntax used to implement the Script drill-down mode is specified in the ODS statement as follows:
ODS HTML
PARAMETERS=(“DRILLDOWNMODE”=“SCRIPT” “DRILLFUNC”=“method”);
The applet parameter DRILLDOWNMODE (see Specifying the Drill-Down Mode) establishes the Script drill-down mode. The DRILLFUNC parameter specifies the name of the JavaScript callback method that is executed in response to drill-down actions.
In response to a drill-down mode. The DRILLFUNC parameter specifies the name of the JavaScript callback method that is executed in response to drill-down actions.
In response to a drill-down action, the applet or control generates an array of arguments that is to be passed into the callback method. The array contains all of the data in the array as it generates its output. As the callback method terminates, it might return an object. The applet or control ignores this object.
To invoke the callback method, the applet or control issues netscape.javascript.JSObject.call() in the following form:
PUBLIC OBJECT CALL(STRING method-name, OBJECT argument-array-name[])
The method-name argument is the name of the callback method that you define in JavaScript in your program. The applet or control supplies the argument-array-name.

Working with the Array of Elements

Understanding the structure of the array of arguments is important for you to be able to access those elements in your callback method. The elements in the array represent all of the variables and values that are represented by the graph element that was selected in the drill-down action. The data is labeled in the array using drill-down tags. The tags identify variable roles or labels and values. For details, see Using Drill-Down Tags and Understanding Variable Roles.
The first element in the array of arguments is the name of the applet or control. The second element in the array is the name of a file. The name of that file is derived from the variable roles in the graph at the preceding drill-down level, using the following substitution string:
{&G_INDEPV,f}
{&G_GROUPV,f}
{&G_SUBGRV,f}.html
The filename is a concatenation of the formatted values of the independent, group, and subgroup variables in the graph at the preceding drill-down level.
Note: The filename and file type are provided as a convenience. If you use this filename and file type, then you must create the actual file and provide its content.
The remaining elements in the array consist of drill-down tags, and the data that is associated with those tags in the graph element that was selected in the drill-down action. Each variable is represented by triplet pairs of arguments in the array:
tag variable_name
tagV variable_value
tagV,F formatted_value
For example assume that each graph data element selected is represented by six arguments in the array.
The graph shown in Example: Script Drill-Down Mode with Java is configured for Script drill-down mode. Selecting the east region sales figures for the state of North Carolina generates the following array:
[appletName East1998NC.html
G_DEP Sales G_DEPV 10000 G_DEPV,F $10,000
G_INDEP Region G_INDEPV East G_INDEPV,F East
G_GROUP Year G_GROUPV 1998 G_GROUPV,F 1998
G_SUBGR State G_SUBGRV NC G_SUBGRV,F NC]
The output filename is East1998NC.html. The remaining triplet pairs capture the roles, and values of the variables that make up the selected data element. All variable names are case sensitive as they appear in the array. For example, the value Region is capitalized. This is the case only if the variable name is defined as Region in the DATA step.

Implementing Script Drill-Down Mode

To implement Script drill-down mode, use PUT statements in a DATA step to write a JavaScript callback method into the HTML output file.
For an example of implementing script drill-down mode, see Example: Script Drill-Down Mode with Java. For information about writing JavaScript, refer to JavaScript tutorials that are available on the Internet.

Formatting Data Values in Script Drill-Down Mode

For Script drill-down mode only, you can specify that data values are to be formatted or not formatted. By default, the values of the variables are not formatted. If the characters ,f are appended to the end of the tag, then those values are presented in formatted form. This parameter tag specifies that the values of the independent variable cost are to appear in formatted form.
{g_inep,f}{cost}
The format is applied using the FORMAT statement in the DATA step or graphics procedure that generated the data for the graph. Formatted values are specified in the statement that generated the original graph. Formatted values are used for axis labels, legends, and data tips that are displayed when the mouse is positioned over a graph data element.

Disabling Drill-Down Functionality

For the Graph applet, you can specify the DISABLEDRILLDOWN parameter to disable the drill-down functionality. Specify the DRILLDOWNMODE parameter as follows in the ODS statement:
ODS HTML
PARAMETERS=(“DISABLEDRILLDOWN”=“TRUE”);