Chapter Contents |
Previous |
Next |
The GCHART Procedure |
Procedure Features: |
| |||||||||||||||
ODS Features: |
| |||||||||||||||
Other Features: |
| |||||||||||||||
Sample library member: | GR13N07 |
For creating output with drill-down for the Web, the example shows how to
For more information, see ODS HTML Statement in SAS/GRAPH Statements.
For creating 3D bar charts, the example shows how to
The introduction to each part lists the VBAR3D options that it features.
The program generates twelve linked bar charts that display data about the world's leading grain producers. The data contain the amount of grain produced by five countries in 1995 and 1996. Each of these countries is one of the three leading producers of wheat, rice, or corn, worldwide.
The first chart, shown in Browser View of Overview Graph as it appears in a browser, is an overview of the data that shows the total grain production for the five countries for both years.
Browser View of Overview Graph
The next two charts break down grain production by year. These charts are linked to the legend values in Browser View of Overview Graph. For example, when you select the legend value for 1995, the graph in Browser View of Year Breakdown for 1995 appears.
Browser View of Year Breakdown for 1995
Another group of charts breaks down the data by country. These charts are linked to the bars. For example, when you drill down on the bar for China in either Browser View of Overview Graph or Browser View of Year Breakdown for 1995, the graph in Browser View of Breakdown for China appears.
Browser View of Breakdown for China
Finally the data is charted by grain type.
These graphs
are linked to the bars in Browser View of Breakdown for China.
If you select the legend value or bar for
Rice
, Browser View of Breakdown for Rice appears.
Browser View of Breakdown for Rice
This program is divided into four parts:
Example 7, Part A |
Features: | VBAR3D options:
| ||||||||||||||||
ODS HTML options:
|
The first part of the program, which includes setting the graphics environment and creating the data set, does the following:
filename odsout 'path-to-Web-server-space'; |
ods listing close; goptions reset=global gunit=pct htitle=6 htext=4 ftitle=zapfb ftext=swiss; |
data newgrain; set grainldr; length yeardrill typedrill countrydrill $ 40; if year=1995 then yeardrill='HREF="year95_body.html"'; else if year=1996 then yeardrill='HREF="year96_body.html"'; |
if type='Corn' then typedrill='HREF="type1_body.html"'; else if type='Rice' then typedrill='HREF="type2_body.html"'; else if type='Wheat' then typedrill='HREF="type3_body.html"'; run; |
proc format; value $country 'BRZ' = 'Brazil' 'CHN' = 'China' 'IND' = 'India' 'INS' = 'Indonesia' 'USA' = 'United States'; run; |
pattern1 color=blue; pattern2 color=green; pattern3 color=cyan; |
legend1 label=none shape=bar(4,4) position=(bottom center) offset=(-3); |
goptions transparency device=gif noborder; |
ods html body='grain_body.html' frame='grain_frame.html' contents='grain_contents.html' path=odsout nogtitle; |
axis1 label=none value=none; |
axis2 label=(angle=90 'Metric Tons (millions)') minor=(n=1) order=(0 to 500 by 100) offset=(0,0); |
axis3 label=none order=('China' 'United States' 'India' 'Indonesia' 'Brazil') split=' '; |
title1 'Corn, Rice, and Wheat Production'; title2 h=2 'Leading Producers for 1995 and 1996'; footnote1 j=l h=3 'click on bars or legend values' j=r h=3 'GRAINALL '; |
html=countrydrill html_legend=yeardrill name='grainall' des='Overview of leading grain producers'; run; |
Example 7, Part B |
Features: | VBAR3D options:
| ||||||||||||
ODS HTML options:
|
In the second part, the PROC GCHART step continues, using RUN-group processing and WHERE statements to produce two graphs of grain production for each year, one of which is shown in Browser View of Year Breakdown for 1995. Each bar represents a country and is subgrouped by grain type. As before, both the bars and the legend values are links to other graphs. The bars link to targets stored in COUNTRYDRILL and the legend values link to targets in TYPEDRILL. These two graphs not only contain links, they are the link targets for the legend values in Browser View of Overview Graph. Before each graph is generated, the ODS HTML statement opens a new body file in which to store the output. Because each of these graphs is stored in a separate file, the HREF attributes that are stored in the variable YEARDRILL point only to the file. The name of the file is specified by the BODY= option in the ODS HTML statement. For example, this is the HREF attribute that points to the graph of 1995 and is stored in the variable YEARDRILL:
HREF=year95_body.htmlYEARDRILL is assigned to the HTML_LEGEND= option in Part A.
ods html body='year95_body.html' path=odsout; |
title1 'Total Production for 1995'; footnote1 j=l h=3 'click on bars or legend values' j=r h=3 'YEAR95 '; |
ods html body='year96_body.html' path=odsout; |
title1 'Total Production for 1996'; footnote1 j=l h=3 'click on bars or legend values' j=r h=3 'YEAR96 '; |
Example 7, Part C |
Features: | VBAR3D options:
| ||||||||||||||||||
ODS HTML
options:
|
The third part produces the five graphs that show the breakdowns by country. These graphs are generated with BY-group processing and are all stored in one body file. When the file is displayed in the browser, all the graphs appear in one frame that can be scrolled. Because the graphs are stored in one file, the links to them must explicitly point to the location of each graph in the file, not just to the file. This location is defined by an anchor. ODS HTML assigns anchor names by default, but you can specify anchor names with the ANCHOR= option. When the procedure uses BY-group processing to generate multiple pieces of output, ODS automatically increments the anchor name to produce a unique name for each graph. This example assigns the base name {mono country} to ANCHOR=. The graphs created by this part are referenced by the COUNTRYDRILL variable. With BY-group processing the catalog entry name also increments automatically. NAME= specifies country as the base name for the graphics output. Because you cannot specify a different description for each graph, DES= specifies a generic description for the HTML Table of Contents.
proc sort data=newgrain out=country; by country; run; |
ods html body='country_body.html' anchor='country' gfootnote path=odsout; |
axis2 order=(0 to 250 by 50) label=none value=none style=0 major=none minor=none noplane; |
axis4 label=none; |
options nobyline; title1 'Breakdown for #byval(country)'; footnote1 j=l h=3 'click on bars'; footnote2 j=c '(Millions of Metric Tons)'; |
Example 7, Part D |
Features: | VBAR3D options:
| ||||
ODS HTML options:
|
Like Part C, this part uses BY-group processing to generate three graphs that show the three leading producers for each type of grain. The program subsets the data and suppresses midpoints with no observations. Instead of storing all of the output in one body file, it stores each graph in a separate file. To do this, the program uses the ODS HTML option NEWFILE=TABLE. When NEWFILE=TABLE is used with BY-group processing, each new piece of output automatically generates a new body file and simply increments the name of the file that is specified by BODY=. Because each graph is stored in a separate file, the links to these graphs reference only the file name and do not require an anchor name. The graphs created by this part are referenced by the TYPEDRILL variable.
proc sort data=grainldr out=type; by type; run; |
ods html body='type1_body.html' newfile=table path=odsout; |
axis5 label=none split=' '; |
title1 'Top Three Producers of #byval(type)'; title2 '(In Millions of Metric Tons)'; footnote j=r h=3 'TYPE '; |
ods html close; ods listing; |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.