creating drill-down graphs using sas/graph® and the …

9
CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE OUTPUT DELIVERY SYSTEM Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA. ABSTRACT Using the SAS/Graph procedures and the Output Delivery System (ODS) you can output your graphs to web-enabled HTML files. Using the flexibility of ODS, you can include the graphs as static GIF or JPEG files, or create interactive, customizable graphs for web distribution using ActiveX controls and JAVA applets. This is really cool stuff. With a few little tricks, you can go a step below a simple HTML graph. Yes, you can add drill-down capability to your HTML graphs. Using this capability, you can create graphs that drill-down to new graphs that display more of the details in your data. Hard to believe? In this paper the author will explore the few SAS statement options necessary to make HTML drill-down graphs a reality. INTRODUCTION With SAS/GRAPH and Output Delivery System, you can easily produce graphs for distribution, including on the web, that are very user-friendly. Web enabling your graphs is simple, if you are running SAS version 8 or 9. If you want your users to be able to drill-down into the details of your graph, you can do that, too. All you have to do is to use the ODS and set a few options. You can chose from a static image, an interactive JAVA applet format, or an interactive ActiveX control format. The static image format will create an HTML document and an associated GIF or JPEG file, while the JAVA and ActiveX formats will create only an HTML document. Below is an example of a JAVA enabled graph. There are many really cool features available to you and your users when you create HTML graphs using JAVA applets and ActiveX controls. Look what happens when you place your cursor over the bars of the graph. Information about the bar is displayed. SAS is not running here. This is just your browser! Is there more? You bet. Right-click with your mouse over the graph. Look at the menu choices given to you. There are many options you can set and change to alter the way the graph looks. If you read my WUSS 2002 paper “Using SAS/Graph and ODS to Web Enabling Your Graphs” then how to create these graphs is old hat. So, I am going to assume you know how to create these. From here we want to go further. Yes, we want to be able to drill down into the details of the graphs we create. Doing so will provide more interactive information to our users. Believe me, if I can do this, so can you. IMPORTANT NOTE! The JAVA and ActiveX graphs require applets and controls to be loaded on the PC to display the graphs. These applets are installed with SAS. However, when distributing the graphs to users who do not have SAS installed on their PC, the applets and controls will need to be installed. The applets and controls contained on a separate CD with the SAS version 8 software

Upload: others

Post on 16-Oct-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE OUTPUTDELIVERY SYSTEM

Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

ABSTRACTUsing the SAS/Graph procedures and the Output DeliverySystem (ODS) you can output your graphs to web-enabledHTML files. Using the flexibility of ODS, you can include thegraphs as static GIF or JPEG files, or create interactive,customizable graphs for web distribution using ActiveXcontrols and JAVA applets. This is really cool stuff. With afew little tricks, you can go a step below a simple HTMLgraph. Yes, you can add drill-down capability to your HTMLgraphs. Using this capability, you can create graphs thatdrill-down to new graphs that display more of the details inyour data. Hard to believe? In this paper the author willexplore the few SAS statement options necessary to makeHTML drill-down graphs a reality.

INTRODUCTIONWith SAS/GRAPH and Output Delivery System, you caneasily produce graphs for distribution, including on the web,that are very user-friendly. Web enabling your graphs issimple, if you are running SAS version 8 or 9. If you wantyour users to be able to drill-down into the details of yourgraph, you can do that, too. All you have to do is to use theODS and set a few options. You can chose from a staticimage, an interactive JAVA applet format, or an interactiveActiveX control format. The static image format will createan HTML document and an associated GIF or JPEG file,while the JAVA and ActiveX formats will create only anHTML document. Below is an example of a JAVA enabledgraph.

There are many really cool features available to you andyour users when you create HTML graphs using JAVAapplets and ActiveX controls. Look what happens when youplace your cursor over the bars of the graph. Informationabout the bar is displayed. SAS is not running here. This isjust your browser!

Is there more? You bet. Right-click with your mouse over thegraph. Look at the menu choices given to you. There aremany options you can set and change to alter the way thegraph looks.

If you read my WUSS 2002 paper “Using SAS/Graph andODS to Web Enabling Your Graphs” then how to createthese graphs is old hat. So, I am going to assume you knowhow to create these. From here we want to go further. Yes,we want to be able to drill down into the details of the graphswe create. Doing so will provide more interactive informationto our users. Believe me, if I can do this, so can you.

IMPORTANT NOTE!The JAVA and ActiveX graphs require applets and controls tobe loaded on the PC to display the graphs. These applets areinstalled with SAS. However, when distributing the graphs tousers who do not have SAS installed on their PC, the appletsand controls will need to be installed. The applets and controlscontained on a separate CD with the SAS version 8 software

Page 2: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

DRILL-DOWN CAPABILITYMy purpose for this paper is to discuss at length the SAScode necessary to create drill-down web-enabled graphsusing ODS. To that end, I will concentrate on the ODS codeand related options necessary to pull this off. I won’t discussat length all of the SAS/GRAPH code that I use to producethe graphs and charts. All of the key SAS/GRAPH code willbe shown, but some of it will not be discussed. (Thecomplete code for the drill-down graphs is at the end of thepaper.) For my example, I will produce a series of bargraphs depicting Major League Baseball home run statisticsby team, league, and division for the 1986 season. My maingraph will show the home run statistics grouped by leagueand sub-grouped by division. I want the user to be able topress on one of the division bars and drill down to a graphthat shows team statistics for that division. There are fourpieces of SAS code that we need to make this work: (1) alittle Data Step trick, (2) a GOPTIONS statement with theDEVICE= option, (3) some ODS statement options, and (4)some unusual SAS/GRAPH procedure options. We willexamine these in order.

(SAS provides a means to drill-down into a graph withoutusing the code method I am about to present. That methoduses the JAVA device and is referred to as “JAVA Drill-downMode”. This second method creates drill-down functionalitybased upon the values stored in the variables defined in theSAS/GRAPH procedure. It is easier to use than the methodI am about to describe, but not as powerful. I will discussthis alternate method briefly at the end of the paper.)

DATA STEP MAGICThe first thing we must do to make our drill-down capabilitya reality is to add a new variable to our input SAS data set.(We could create two new variables as we will see later.)The new variable will contain a literal HTML reference to thegraph(s) we want to display when we drill down. Take a lookbelow at the Data Step we use to create the variable in theSAS data set.

In this Data Step, we create a work SAS data set namedbaseball by reading the permanent SAS data set alsonamed baseball. (I generated this sample SAS data setusing SAS/ASSIST.) The SAS data set contains baseballstatistics for players of the 1986 season. Each row contains,among other things, the team, league, and division to whichthe player belongs. The point of the Data Step is to createa new file containing the variable named DIVISIONDRILL.That variable will be filled with one of four values for anHTML file reference: one for each of the combinations ofleague and division (American League Eastern Division,American League Western Division, National League

Eastern Division, National League WesternDivision). We assigned each of the fourvalues based on the values of the two

variables LEAGUE and DIVISION. (If youare not familiar with Major LeagueBaseball, you are missing out: it’sAmerica’s pastime, you know.)

Here is what our new SAS data set now looks like. Noticethe DIVISIONDRILL variable we created.

IMPORTANT GOPTIONSFollowing is the GOPTIONS statement that we need in ourcode. The DEVICE= is the piece where we will focus ourattention.

There are several device choices you can make that willdetermine the type of output you will get. The essentialchoices are ACTIVEX, JAVA, HTML, GIF, and JPEG. If youselect DEVICE=ACTIVEX, SAS will create an HTML fileusing ActiveX controls. If you select DEVICE=JAVA, SASwill create an HTML file using JAVA applets. The ActiveXand JAVA enabled graphs will look and behave like theexamples we saw at the beginning of the paper. If you selectDEVICE=HTML or GIF, SAS will create an HTML file with alink to a GIF file, with the GIF file being a static image of thegraph. If you select DEVICE=JPEG, SAS will create anHTML file with a link to a JPEG file, with the JPEG file beinga static image of the graph. Some people still debate whichis better: a JPEG file or a GIF file. Well, I was always taughtthat choosy mothers choose GIF!

data baseball;

set data.baseball;

length divisiondrill $ 40;

if league='American' and

division='West' then

divisiondrill=

'HREF="divisionALwest_body.html"';

else if league='American' and

division='East' then

divisiondrill=

'HREF="divisionALeast_body.html"';

else if league='National' and

division='West' then

divisiondrill=

'HREF="divisionNLwest_body.html"';

else if league='National' and

division='East' then

divisiondrill=

'HREF="divisionNLeast_body.html"';

run;

goptions reset=global pixels=650

ypixels=450 device=java;

Page 3: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

REALLY IMPORTANT NOTE!There are many SAS/GRAPH GOPTIONS and otherstatement options that are just not supported by theJAVA and ActiveX devices. Using the unsupportedoptions will not generate an error in the SAS log, but willgenerate a note in the log. There are too manyunsupported options to document in this paper. But, theSAS Institute does have technical support documentsTS601 and TS602 that detail the unsupported options.You can find these documents at:http://ftp.sas.com/techsup/download/technote/ts601.htmlhttp://ftp.sas.com/techsup/download/technote/ts602.html

While not critical for our drill-down graphs, the GOPTIONSstatement with the XPIXEL= and YPIXEL= options definesthe number of pixels used for the X and Y axis of the graph.The larger these are, the bigger the graphics image will be.Values of 650 and 450 for XPIXEL and YPIXEL,respectively, seem to work well.

ODS STATEMENT OPTIONSThe are a few important options within the ODS statementthat you may not be familiar with. We will examine these indepth. To start, take a look at the ODS code and relatedoptions.

This code begins with the familiar ODS HTML statement.We have directed the output to a body file called “c:\wuss2003\baseball_body.html”, and have added a title to theHTML window “ODS Drill-Down Chart”. We will also createsimilar named files for the HTML contents and frame. Youmight notice that we have not specify the location of the filesin the ODS HTML statement. Instead we used the PATHoption that refers to the path we defined in a Filenamestatement. And, we have added the familiar STYLE optionand selected my favorite style, “STATDOC”. The rest of thestuff on the ODS statement probably looks unfamiliar. Wewill spend some of our time looking at these options.

The GPATH OptionThe GPATH option is important if you are usingDEVICE=HTML, GIF, or JPEG. This option tellsSAS/GRAPH where to store the GIF or JPEG file(s) it willcreate and associate with the HTML file(s) it will also create.You will probably want to specify the same location as theHTML file defined as the ODS output file. I have found thatunder SAS for Windows if I do not use the GPATH optionwhen using device HTML, GIF, or JPEG that SAS/GRAPHwill place the graphics image in the SAS root folder. I have

also found that without the GPATH option and if the HTMLand the GIF or JPEG file(s) are not created in the samelocation, there will be no link in the HTML file to the graphicsimage. When this happens, your browser will display theicon it uses in place of a graphics file that it cannot find. Andwhen this happens, it won’t help to later move the graphicsfile to the same location as the HTML file, because there isno linkage in the HTML file to the graphics file. If you dospecify a GPATH when creating a GIF or JPEG file you canspecify a location other than the location of the HTML file.Using the GPATH option causes SAS/GRAPH to include inthe HTML file the linkage to the graphics file. But, I havefound that if you use the PATH option with a Fileref, thenyou don’t need the GPATH option, as long as you want theGIF or JPEG file in the same location as the Fileref location.

The PARAMETERS= OptionThis option is the big one - but there is only one parametercritical to our drill-down graphs. There are a great manythings you can control and customize about your graph andits associated HTML file with the parameters= option. Icovered those in my WUSS 2002 paper “Using Sas/graphand ODS to Web Enabling Your Graphs”. The form of theparameters= option is:

parameters=(“parameter-name”=”parameter-value”)

There are several parameters necessary to control theinternal JAVA drill-down mode capability. However, whenyou do not want to use the JAVA drill-down mode, you mustdisable it to avoid conflicting with the drill-down capability wehave been discussing. To accomplish this, we use the“DisableDrilldown” parameter, which specifies that theinternal JAVA drill-down should be disabled for this graph.The value of the parameter does not matter, but a valuemust be specified as different browsers handle null valuesdifferently. Its presence indicates that internal JAVA drill-down should be disabled. Drill-down can again be enabledby the user using the pop-up menu when browsing the web-enabled graph.

Remember, if you are going to create drill-down graphsusing the method we have been discussing, then internalJAVA drill-down must be disable to get predictable results.

SAS/GRAPH CODE and OPTIONSThere are, of course, many statements and options to useto tweak your graph output to your liking. There are two verycritical ODS related options that have been added to theSAS/GRAPH procedures. These are the HTML andHTML_Legend options. It is these two options that make thedrill-down capability work. These options are defined by SASas follows:

filename odsout 'c:\wuss 2003';

ods html body='baseball_body.html'

(title="ODS Drill-Down Chart")

frame='baseball_frame.html'

contents='baseball_contents.html'

path=odsout

gtitle gfootnote style=statdoc

gpath='c:\wuss 2003'

parameters=("disabledrilldown"="true");

IMPORTANT NOTE!I have found documentation on these options difficult tofind. According to the SAS Institute, the only place tofind documentation is in the SAS for Windows on-linehelp. Here’s how to find the help. While in SAS forWindows, from the menus, select Help º SAS SystemHelp. Then select the SEARCH tab and search on“applet parameters”. From the list of found entries,select “GraphApplet Parameters” and “SAS GlobalStatements: ODS HTML Statement - Options”.

Page 4: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

HTML=variableIdentifies the variable in the input data set whosevalues create links in the HTML file created by the ODSHTML statement. These links are associated with anarea of the chart and point to the data or graph youwish to display when the user drills down on the area.

HTML_LEGEND=variableIdentifies the variable in the input data set whosevalues create links in the HTML file created by the ODSHTML statement. These links are associated with alegend value and point to the data or graph you wish todisplay when the user clicks on a legend value.

So, what does this mean? Here’s how these work. If youwant your user to be able to drill-down by pressing on aportion of the graph (a bar for example) then you set thevalue of the HTML option to a variable name in the SASdata set that will be used to create the graph. In the SASdata set in that variable, you will already have stored a stringvalue that is the name of the HTML file that you want to callwhen the user presses the appropriate portion of the graph.If you want your user to drill down when pressinga portion of the legend then you follow the sameprocess but use the HTML_Legend option.

Sound confusing? Remember our Data Steptrick? We created the DIVISIONDRILL variablein our input data set. In our example, thatvariable holds one of four possible HTMLreferences. We want our main graph to drilldown to one of the four HTML references whenthe user presses one of the graph bars or legend areas. So,we assign the DIVISIONDRILL variable to both the HTMLand HTML_LEGEND options. Harken back to my earlierstatement that we could create one or two new variables inour input data set. In our examples, We created one that wewill use for both the HTML and HTML_LEGEND options.However, we could have created two new variables in ourinput SAS data set and used one for the HTML option andthe other for the HTML_LEGEND option.

Next, take a look at the SAS/GRAPH code.

If you are familiar with the GCHART procedure, most of thisstuff looks familiar. (Of course, I have left out much of thecode that we need to make the chart look good. And, ofcourse, you can use other SAS/GRAPH procedures.) Youwill find in this example the HTML and HTML_Legendoptions. Notice that they refer to the variableDIVISIONDRILL that we created in the work.baseball SASdata set. So, what is this option doing for us? Well, when the

GCHART procedure creates a bar graph, it will use thevalue in the variable DIVISIONDRILL to specify the name ofanother HTML file we will create in a minute. This otherHTML file will be linked and executed when a user pressesa bar or legend in our bar graph.

Take a look at the HTML source code for the output file wejust created in the baseball_contents.html file. You willnotice the HREF we specified in our DIVISIONDRILLvariable. What we see in the HTML source code will differdepending on the DEVICE= option we use.

proc gchart data=baseball;

vbar3d division / discrete

sumvar=no_home

group=league

legend=legend1

html=divisiondrill

html_legend=divisiondrill;

run;

<dt><b>&#183;</b><A

HREF="divisionALwest_body.html#IDX1"

TARGET="body">American League West 1986

Home Runs</a>

<dt><b>&#183;</b><A

HREF="divisionALeast_body.html#IDX2"

TARGET="body">American League East 1986

Home Runs</a>

<dt><b>&#183;</b><A

HREF="divisionNLwest_body.html#IDX3"

TARGET="body">National League West 1986

Home Runs</a>

<dt><b>&#183;</b><A

HREF="divisionNLeast_body.html#IDX4"

TARGET="body">National League East 1986

Home Runs</a>

Var1.Append("East");

Var2.Append("East");

Var3.Append("American");

Var4.Append(1106);

Var2.AppendFrequency(85);

Var6.Append("divisionALeast_body.html");

Var1.Append("West");

Var2.Append("West");

Var3.Append("American");

Var4.Append(1079);

Var2.AppendFrequency(90);

Var6.Append("divisionALwest_body.html");

Var1.Append("East");

Var2.Append("East");

Var3.Append("National");

Var4.Append(678);

Var2.AppendFrequency(72);

Var6.Append("divisionNLeast_body.html");

Var1.Append("West");

Var2.Append("West");

Var3.Append("National");

Var4.Append(712);

Var2.AppendFrequency(75);

Var6.Append("divisionNLwest_body.html");

Page 5: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

Take a look at the source code above for the output we justcreated in the baseball_body.html file. You will notice theHREF we specified in our DIVISIONDRILL variable.

I know it’s a bit cluttered, but notice the same four strings wespecified in the DIVISIONDRILL variable. SAS placed thevalues of that variable in the HTML file to trigger a hyperlinkto the four other HTML graph files we created. Below is oneof the four division charts.

Now, take a look at the ODS statement and SAS/GRAPHcode for the four subordinate bar charts that we will create.These four bar charts will be the charts for the combinationsof the leagues and divisions.

Notice carefully that the name of the HTML file that we arecreating exactly matches the values we placed in theDIVISIONDRILL variable. Also, notice that while we have aseparate ODS HTML statement for the separate HTML files,we do not use another GCHART procedure. We simplyissue additional VBAR3D statements to create the othergraphs within the same execution of the GCHARTprocedure. Also, note the very important WHEREstatements. It is here that we subset our SAS data set tocreate the subordinate graphs for each combination of

league and division. You can create drill-down graphs to anylevel you like. You just have to create more variables in yourinput SAS data set to hold the values of the HTML files youwant to link to the graph areas.

The SAS on-line documentation forSAS/GRAPH has additionalexamples of drill-down graphs.

RESULTSTo the code we have already seen, you can simply addsome trusty LEGEND, AXIS, TITLE, and FOOTNOTEstatements, and use a graphing procedure, such as theGCHART procedure. Let’s see what we can do to a drill-down bar chart.

Nice chart. Moving the mouse over any one of the four barschanges the mouse shape to a hand (or, whatever Windowsscheme you are using). Once your user gets a hand, youruser can press the mouse button, and like magic, your userwill drill down into another, related graph.

ods html body='divisionALwest_body.html'

path=odsout;

where league='American' and

division='West';

vbar3d team / sumvar=no_home

subgroup=team

shape=PRISM patternid=subgroup;

run;

ods html body='divisionALeast_body.html'

path=odsout;

where league='American' and

division='East';

vbar3d team / sumvar=no_home

subgroup=team

shape=PRISM patternid=subgroup;

run;

ods html body='divisionNLwest_body.html'

path=odsout;

where league='National' and

division='West';

vbar3d team / sumvar=no_home

subgroup=team

shape=PRISM patternid=subgroup;

run;

ods html body='divisionNLeast_body.html'

path=odsout;

where league='National' and

division='East';

vbar3d team / sumvar=no_home

subgroup=team

shape=PRISM patternid=subgroup;

run;

Page 6: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

Beautiful, isn’t it? SAS/GRAPH and ODS work together sowell.

INTERNAL JAVA DRILL-DOWN MODEBut, what about that second method I mentioned that onlyrequires the use of all those ODS parameter= values. Well,you can exclude the DisableDrilldown parameter option, useDEVICE=JAVA, don’t create a SAS data set with the HTMLstrings, and don’t use the SAS/GRAPH HTML andHTML_LEGEND options. Then, SAS will use the ODSparameter= options to create internal JAVA drill-downfunctionality. The drill-down capability will be within a singlegraph. The SAS documentation on the parameter= optionsis meager. But I did find some additional help on the SASweb site in a file called “javaapplets.html”. Here’s animportant quote from that help document.

The drill-down modes in the SAS/GRAPH Applets forJAVA are data-driven, which means that the targetaddresses that they go to are constructed dynamically,based on the data values contained in a selected graphelement. This contrasts with the drill-down capabilities ofGIF images [the method I just presented], which arebased on pixel areas that are linked to target locationsthat are statically defined in an HTML file.

About the only thing you need to customize the internalJAVA drill-down mode is several parameter options. We metthe Parameters= option earlier because we needed to turnoff the internal JAVA drill-down mode. Let’s look at thisoption as it relates to the internal JAVA drill-down modemore carefully.

The PARAMETERS= OptionThe form of the parameters= option is:

parameters=(“parameter-name”=”parameter-value”)

Following are the parameters that can be used to control theinternal JAVA drill-down capabilities. These options are onlyapplicable when the DisableDrilldown parameter is set to“false”, or is not present.

DdLevelnSpecifies internal drill-down level specifications.

DisableDrilldownSpecifies that the internal JAVA drill-down should bedisabled for this graph. The value of the parameter does notmatter, but a value must be specified as different browsershandle null values differently. Its presence indicates thatinternal JAVA drill-down should be disabled. Drill-down canagain be enabled by the user using the pop-up menu.

DrillDownFunction | DrillFunc Specifies the name of the JAVAScript function to call whenDrillDownMode is set to "Script".

DrillDownModeSpecifies the drill-down mode to use when drilling down. Thedefault is "Any". Valid values are as follows.Any In this mode, the graph first attempts to drill-down

using “Local” mode. If that fails, it attempts to drill-down using JAVAScript (“Script”). If both these fail,the graph attempts to drill-down using “URL” mode.If all these fail, the graph attempts to drill-downusing “HTML” mode.

HTML This mode loads an HTML page whose URL isdetermined by the data values of the selectedgraph element.

Local This mode drills down to a new graph thatorganizes data according to the valuesrepresented by the selected graph element, usingthe current local graph formatting selections (color,shape, etc.). This mode is enabled by theGraphApplet only.

Script This mode invokes the user specified JAVAScriptfunction with information about the selected chartelements. The user function is expected to performthe requested drill-down action.

URL This mode uses a pre-defined pixel map (alsoknown as an image map) to load a specified HTMLfile based on the location of a mouse click. Thispixel-based mode differs from the data-drivenLocal, Script, and HTML modes, which rely on thedata associated with the selected graphics elementto determine the outcome of the drill-down action.

DrillPatternSpecifies the drill-down pattern when DrillDownMode isHTML.

DrillTargetSpecifies the drill-down window target to use when drillingdown using HTML mode. The default is "_blank".

HelpLocationSpecifies the URL from which the graph is to display help.The default is the help location for a particular applet releasethat SAS Institute provides on its external Web site. Theparameter can be either “Default” or a valid URL.

LocaleSpecifies the language and country to use when displayinglocale-sensitive strings. The default is to use the regionsettings of the browser's host machine. This parameter canbe used to override the browser's default locale.

PatternStripSpecifies that preceding and trailing white space are to beremoved from drill-down substitution patterns before adding

IMPORTANT NOTE!I have found documentation on the internal JAVA drill-down mode difficult to find. According to the SASInstitute, the only place to find documentation is in theSAS for Windows on-line help. Here’s how to find thehelp. While in SAS for Windows, from the menus, selectHelp º SAS System Help. Then select the SEARCH taband search on “applet parameters”. From the list offound entries, select the following:“GraphApplet Parameters”“Working with Java Drill-Down Modes”“Working with the Script Drill-Down Mode”“Working with the Local Drill-Down Mode”“Working with the HTML Drill-Down Mode”“Drill-Down Tags for the Java Applets”

Page 7: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

to them the generated drill-down string. A value of “True”causes the removal the white spaces; a value of “False”leaves the white spaces. The default is “False.”

The Code and BehaviorAs you can see, the code is much simpler than the codeexample we previously examined. As was true of ourprevious example, the code below does not include all of theSAS/GRAPH statements to make our graphs look good. But,the code below does contain all the critical elements for theinternal JAVA drill-down mode.

The trick to the internal JAVA drill-down mode is that allvariables we want to be able to drill downto must be present in our single graphprocedure. So, unlike the code methodwe looked at earlier, here our GCHARTprocedure includes both a GROUP andSUBGROUP. Without the SUBGROUPwe would not be able to drill down to theTEAM variable.

Take a look at the results on the opposite column. The firstgraph includes the teams subgrouped within the divisions.Pressing on one of the division bars drills down to a newgraph that includes the division selected along with thedivision in the other league (I pressed the American LeagueWest bar and the resulting graph includes the AmericanLeague West and National League West. Pressing a bar onthe resulting graph results in a new graph containing eachteam in the division selected.

filename odsout 'c:\wuss 2003';

goptions reset=global pixels=650

ypixels=450 device=java;

ods html body='baseball_body_java.html'

(title="ODS Drill-Down Chart")

path=odsout

gtitle gfootnote style=statdoc

gpath='c:\wuss 2003'

parameters=("ddlevel2"

"disabledrilldown"="false"

"drilldownfunction"=""

"drilldownmode"="local"

"drillpattern"=""

"drilltarget"=""

"helplocation"="default"

"locale"=""

"patternstrip"="false");

proc gchart data=data.baseball;

vbar3d division / discrete

sumvar=no_home

group=league

subgroup=team

run;

quit;

ods html close;

Page 8: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

One of the differences you will notice between the two drilldown methods is that with the internal JAVA drill down modeyou cannot control the look of the drill-down graphs. Forexample, notice that there is no descriptive title on the drill-down graph indicating which league and division isrepresented. Which of the two methods is better? That mightdepend on what you need to accomplish.

CONCLUSIONAs I mentioned in the beginning of the paper- if I can createdrill-down graphs with SAS/GRAPH and ODS, then anyonecan. This is actually pretty simple stuff. Give it a try. You arejust a few minutes away from creating your own examples ofweb-enabled drill-down graphs. My SAS code is shown onthe next page. Due to space constraints, I only show thecode for one of the four subordinate bar charts. The otherthree follow the same pattern.

REFERENCESSAS JAVA applets and ActiveX controls available at:

http://www.sas.com/apps/apps/demosdownloads/activex_prod_81_downarea.jsp?productID=100037

A handy SAS Institute document describing web-enablinggraphs, especially using drill-down capabilities can be foundat:

http://www.sas.com/apps/apps/demosdownloads/activex_prod_81_downarea.jsp?productID=100038

CONTACT INFORMATIONYour comments and questions are valued and encouraged.Contact the author at:

Curtis A. SmithDefense Contract Audit AgencyP.O. Box 20044Fountain Valley, CA 92728-0044Work Phone: 714-896-4277Fax: 714-896-6915Email: [email protected]

Page 9: CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH® AND THE …

/* Begin ODS output */libname data 'c:\wuss 2003';filename odsout 'c:\wuss 2003';data baseball; set data.baseball; length divisiondrill $ 40; if league='American' and division='West' then divisiondrill='HREF="divisionALwest_body.html"'; else if league='American' and division='East' then divisiondrill='HREF="divisionALeast_body.html"'; else if league='National' and division='West' then divisiondrill='HREF="divisionNLwest_body.html"'; else if league='National' and division='East' then divisiondrill='HREF="divisionNLeast_body.html"'; run;pattern1 color=blue;pattern2 color=green;pattern3 color=cyan; pattern1 color=yellow;pattern2 color=violet;pattern3 color=orange;legend1 label=none shape=bar(4,4) position=(bottom left) offset=(-3);ods listing close;goptions reset=global gunit=pct xpixels=650 ypixels=600 htitle=5 htext=4 ftitle=zapfb ftext=swiss colors=(yellow green red purple orange blue) transparency device=java noborder;ods html body='baseball_body.html' (title="ODS Drill-Down Chart") frame='baseball_frame.html' contents='baseball_contents.html' path=odsout gtitle gfootnote style=statdoc gpath='c:\wuss 2003 parameters=("disabledrilldown”="true");axis1 label=none value=none;axis2 label=(angle=90 'Sum of Home Runs') minor=(n=1) offset=(0,0);axis3 label=none split=' ';title1 'Major League Baseball Home Run Statistics';title2 h=2 '1986 Season';proc gchart data=baseball; vbar3d division / discrete sumvar=no_home group=league subgroup=division legend=legend1 space=0 width=5 gspace=5 maxis=axis1 raxis=axis2 gaxis=axis3 outline=black cframe=pink html=divisiondrill name='MLB' des='Major League Baseball Home Run Statistics';run;ods html body='divisionALwest_body.html' path=odsout;title1 'American West';format team $team.;where league='American' and division='West';vbar3d team / sumvar=no_home type=sum group=division subgroup=team autoref space=3 shape=PRISM patterned=subgroup inside=SUM coutline=black raxis=axis2 cframe=pink name='ALWest' des='American League West 1986 Home Runs';run;quit; ods html close;ods listing;