Sample 25262: Pie charts with drill down functionality
This sample creates a Java applet that can be used to display a pie chart with HTML drilldown capability. To create the applet, run this SAS/GRAPH code. This graph highlights many features of the Java applet such a s how to use data tips, change the view of the chart, change the appearance of the chart, change the variables, and utilize HTML drill down.
To display additional information about a section of the graph, use your mouse cursor to point to a section of the pie chart. Click a portion of the graph (a pie slice) to display detailed information about that area of the graph.
To modify the chart, place the mouse pointer anywhere on the graph and click the right mouse button (RMB). Select items on the pop-up menu to modify features of the chart such as the Legend, Variables, and Chart Tips.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* This sample contains options or statements that were not available until */
/* Release 8.2 of the SAS System. Running this sample in a prior release */
/* may not produce the expected results. */
/* NOTE: If you are accessing the jar files on a server you will need to */
/* point to the location of those files by specifying the CODEBASE= option */
/* for your ODS HTML statement. */
/* This is the only line you have to change to run the program. Specify the */
/* location in your file system where the html files will be stored. */
filename odsout 'directory where you want to store html files';
/* Close the listing destination */
ods listing close;
/* Open the HTML destination for ODS output */
ods html file="newspapers.html"
path=odsout
CODEBASE="HTTP://name-of-server/directory where applets are stored"
parameters=("DISABLEDRILLDOWN"="TRUE");
/* Assign graphics options for ODS output */
goptions reset=all
device=java
xpixels=500 ypixels=350
cback=white
border;
/* Create data set ADVERTISING */
data advertising;
format Revenue dollar12.;
input Media $ 1-18 Year Revenue Share;
datalines;
newspapers 1985 25170 26.6
newspapers 1990 28280 25.1
newspapers 1995 35000 22.5
newspapers 1996 40000 21.8
newspapers 1997 35000 22.1
tv 1985 20298 21.4
tv 1990 25000 20.7
tv 1995 28000 20.0
tv 1996 34046 20.6
tv 1997 20893 19.7
radio 1985 8000 6.8
radio 1990 20726 6.8
radio 1995 11338 7.1
radio 1996 12269 7.0
radio 1997 13491 7.2
;
run;
/* Subset data set ADVERTISING to create data set NEWS */
data news;
set advertising (where=(media=:"newspapers"));
run;
title1 "Advertising Revenue Growth for Newspapers by Year";
pattern1 c=CX6173A9; /*periwinkle*/
pattern2 c=CX8DA642; /*apple green*/
pattern3 c=CX98341C; /*mulberry*/
pattern4 c=CXFCD861; /*yellow orange*/
pattern5 c=CX8AA4C9; /*light periwinkle*/
/* This PROC produces a bar chart of Revenues by Year */
/* for Newspapers. */
proc gchart data=news;
vbar year / sumvar=Revenue
patternid=midpoint
discrete;
run;
quit;
/* Close the HTML destination */
ods html close;
/* Subset data set ADVERTISING to create data set TV */
data tv;
set advertising (where=(media=:"tv"));
run;
/* Open the HTML destination for ODS output */
ods html file="tv.html"
path=odsout &codebse
parameters=("DISABLEDRILLDOWN"="TRUE");
title1 "Advertising Revenue Growth for TV by Year";
/* Produce a bar chart of Revenues by Year for TV */
proc gchart data=tv;
vbar year / sumvar=Revenue
patternid=midpoint
discrete;
run;
quit;
/* Close the html destination */
ods html close;
/* Subset data set ADVERTISING to create data set RADIO */
data radio;
set advertising (where=(media=:"radio"));
run;
/* Open the HTML destination for ODS output */
ods html file="radio.html"
path=odsout &codebse
parameters=("DISABLEDRILLDOWN"="TRUE");
title1 "Advertising Revenue Growth for Radio by Year";
/* Produce a bar chart of Revenues by Year for Radio */
proc gchart data=radio;
vbar year / sumvar=Revenue
patternid=midpoint
discrete;
run;
quit;
/* Close the HTML destination */
ods html close;
/* Open the HTML destination for ODS output */
ods html file="advertising.html"
path=odsout &codebse
parameters=("DRILLDOWNMODE"="HTML"
"DRILLTARGET"="_self"
"DRILLPATTERN"='{&G_INDEPV}.html');
title1 "Advertising Revenue Growth";
/* Produce a pie chart of Revenues by Media */
proc gchart data=advertising;
pie3d Media / sumvar=Revenue
coutline=black
legend
explode='tv'
discrete;
run;
quit;
/* Close the HTML destination */
ods html close;
/* Open the listing destination */
ods listing;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This code produces an HTML file with a Table of Contents (TOC).
Click here to see the frameset:
See the frameset
This sample uses the Java device driver to create an interactive pie chart with HTML drill down capability.
| Type: | Sample |
| Topic: | Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Pie SAS Reference ==> Procedures ==> GCHART Third Party ==> Output ==> Device Drivers ==> Java SAS Reference ==> ODS (Output Delivery System)
|
| Date Modified: | 2006-07-13 03:02:43 |
| Date Created: | 2005-03-09 08:29:50 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8.2 TS2M0 | n/a |