| Features: |
VBAR statement
|
| Other features: |
GOPTIONS statement option: BORDER |
/* Create the temporary data set named sales. */
data sales;
length Region $ 4 State $ 2;
format Sales dollar8.;
input Region State Sales Year Qtr;
datalines;
West CA 13636 1999 1
West OR 18988 1999 1
West CA 14523 1999 2
West OR 18988 1999 2
East MA 18038 1999 1
East NC 13611 1999 1
East MA 11084 1999 2
East NC 19660 1999 2
West CA 12536 1998 1
West OR 17888 1998 1
West CA 15623 1998 2
West OR 17963 1998 2
East NC 17638 1998 1
East MA 12811 1998 1
East NC 12184 1998 2
East MA 12760 1998 2
;
/* Use an IF/THEN statement to assign values to the variable RPT. */
data sales;
set sales;
if state in ("NC" "MA") then
RPT="title='North Carolina and Massachusetts'";
if state in ("CA" "OR") then RPT="title='California and Oregon'";
run;
/* Reset the graphics options to their defaults and specify a border. */
goptions reset=all border;
/* Close the current ODS HTML destination. */
ods html close;
/* Open the HTML destination and specify the ODS output filename */
/* and style. */
ods html file="datatips.htm" style=listing;
/* Generate the bar chart. Add the HTML= option to associate */
/* the custom data tips with each graph element. */
title "Company Sales, Mid Year";
proc gchart data=sales;
vbar region / sumvar=sales
group=year
html=RPT;
run;
quit;
/* Close ODS HTML to close the output file, and then reopen it. */
ods html close;
ods html;| Features: |
VBAR statement
|
| Other features: |
AXIS statement BY statement FORMAT statement
LEGEND statement RUN-group processing TITLE statement WHERE statement |
| Sample library member: | GCHDDOWN |



Rice, Browser View of Breakdown for Rice appears.
filename odsout ".";
goptions reset=all xpixels=550 ypixels=500 cback=white;
data grainldr; length country $ 3 type $ 5; input year country $ type $ amount; format megtons comma5.0; megtons=amount/1000; datalines; 1995 BRZ Wheat 1516 1995 BRZ Rice 11236 1995 BRZ Corn 36276 1995 CHN Wheat 102207 1995 CHN Rice 185226 1995 CHN Corn 112331 1995 IND Wheat 63007 1995 IND Rice 122372 1995 IND Corn 9800 1995 INS Wheat . 1995 INS Rice 49860 1995 INS Corn 8223 1995 USA Wheat 59494 1995 USA Rice 7888 1995 USA Corn 187300 1996 BRZ Wheat 3302 1996 BRZ Rice 10035 1996 BRZ Corn 31975 1996 CHN Wheat 109000 1996 CHN Rice 190100 1996 CHN Corn 119350 1996 IND Wheat 62620 1996 IND Rice 120012 1996 IND Corn 8660 1996 INS Wheat . 1996 INS Rice 51165 1996 INS Corn 8925 1996 USA Wheat 62099 1996 USA Rice 7771 1996 USA Corn 236064 ;
proc format;
value $country
"BRZ" = "Brazil"
"CHN" = "China"
"IND" = "India"
"INS" = "Indonesia"
"USA" = "United States";
data newgrain;
set grainldr;
length yeardrill typedrill countrydrill $ 100;
/* Assign targets for the YEAR values. */
yeardrill=
"TITLE="||quote(trim(left(year)))||' '||
"HREF="||quote('year'||trim(left(year))||'_body.html');
/* Assign targets for the COUNTRY values. */
countrydrill=
"TITLE="||quote(trim(left(put(country,$country.))))||' '||
"HREF="||quote('country_body.html#'||trim(left(country)));
/* Assign targets for the TYPE values. */
typedrill=
"TITLE="||quote(trim(left(type)))||' '||
"HREF="||quote(trim(left(type))||'_body.html');
legend1 label=none shape=bar(.15in,.15in) position=(bottom center);
ods html close;
goptions device=png;
ods html body="grain_body.html" frame="grain_frame.html" contents="grain_contents.html" gtitle gfootnote style=listing path=odsout;
axis1 label=none value=none;
axis2 label=(angle=90 "Metric Tons (millions)") minor=none order=(0 to 500 by 100) offset=(0,0);
axis3 label=none
order=("China" "United States" "India" "Indonesia" "Brazil")
split=" " offset=(4,4);
title1 ls=1.5 "Corn, Rice, and Wheat Production"; title2 "Leading Producers for 1995 and 1996"; footnote1 ls=1.3 "Click the bars or legend colors to drill down.";
proc gchart data=newgrain;
format country $country.;
vbar year / discrete type=sum sumvar=megtons
group=country
subgroup=year
space=0
maxis=axis1
gaxis=axis3
raxis=axis2
autoref cref=graydd clipref
legend=legend1
html=countrydrill
html_legend=yeardrill
name="grainall"
des="Overview of leading grain producers";
run;
quit;
data grainldr; length country $ 3 type $ 5; input year country $ type $ amount; format megtons comma5.0; megtons=amount/1000; datalines; 1995 BRZ Wheat 1516 1995 BRZ Rice 11236 1995 BRZ Corn 36276 1995 CHN Wheat 102207 1995 CHN Rice 185226 1995 CHN Corn 112331 1995 IND Wheat 63007 1995 IND Rice 122372 1995 IND Corn 9800 1995 INS Wheat . 1995 INS Rice 49860 1995 INS Corn 8223 1995 USA Wheat 59494 1995 USA Rice 7888 1995 USA Corn 187300 1996 BRZ Wheat 3302 1996 BRZ Rice 10035 1996 BRZ Corn 31975 1996 CHN Wheat 109000 1996 CHN Rice 190100 1996 CHN Corn 119350 1996 IND Wheat 62620 1996 IND Rice 120012 1996 IND Corn 8660 1996 INS Wheat . 1996 INS Rice 51165 1996 INS Corn 8925 1996 USA Wheat 62099 1996 USA Rice 7771 1996 USA Corn 236064 ;
proc format;
value $country
"BRZ" = "Brazil"
"CHN" = "China"
"IND" = "India"
"INS" = "Indonesia"
"USA" = "United States";
data newgrain;
set grainldr;
length yeardrill typedrill countrydrill $ 100;
/* Assign targets for the YEAR values. */
yeardrill=
"TITLE="||quote(trim(left(year)))||' '||
"HREF="||quote('year'||trim(left(year))||'_body.html');
/* Assign targets for the COUNTRY values. */
countrydrill=
"TITLE="||quote(trim(left(put(country,$country.))))||' '||
"HREF="||quote('country_body.html#'||trim(left(country)));
/* Assign targets for the TYPE values. */
typedrill=
"TITLE="||quote(trim(left(type)))||' '||
"HREF="||quote(trim(left(type))||'_body.html');
ods html body="grain_body.html" frame="grain_frame.html" contents="grain_contents.html" gtitle gfootnote style=listing path=odsout;
axis3 label=none
order=("China" "United States" "India" "Indonesia" "Brazil")
split=" " offset=(4,4);
title1 ls=1.5 "Corn, Rice, and Wheat Production"; title2 "Leading Producers for 1995 and 1996"; footnote1 ls=1.3 "Click the bars or legend colors to drill down.";
proc gchart data=newgrain;
format country $country.;
vbar year / discrete type=sum sumvar=megtons
group=country
subgroup=year
space=0
maxis=axis1
gaxis=axis3
raxis=axis2
autoref cref=graydd clipref
legend=legend1
html=countrydrill
html_legend=yeardrill
name="grainall"
des="Overview of leading grain producers";
run;
quit;
HREF=year1995_body.htmlYEARDRILL is assigned to the HTML_LEGEND= option in Part A.
axis4 label=none
order=("China" "United States" "India" "Indonesia" "Brazil")
split=" " offset=(8,8);
%macro do_year(year);
ods html body="year&year._body.html" gtitle gfootnote path=odsout style=listing;
title1 ls=1.5 "Total Production for &year";
proc gchart data=newgrain (where=(year=&year));
format country $country.;
vbar country / type=sum sumvar=megtons
subgroup=type
legend=legend1
raxis=axis2
maxis=axis4
width=8
autoref cref=graydd clipref
html=countrydrill
html_legend=typedrill
name="year_&year"
des="Production Breakdown for &year";
run;
quit;
%mend do_year;
%do_year(1995); %do_year(1996);
axis4 label=none
order=("China" "United States" "India" "Indonesia" "Brazil")
split=" " offset=(8,8);
proc gchart data=newgrain (where=(year=&year));
format country $country.;
vbar country / type=sum sumvar=megtons
subgroup=type
legend=legend1
raxis=axis2
maxis=axis4
width=8
autoref cref=graydd clipref
html=countrydrill
html_legend=typedrill
name="year_&year"
des="Production Breakdown for &year";
run;
quit;axis5 label=none split=" " offset=(4,4);
axis6 label=(angle=90 "Metric Tons (millions)") minor=none order=(0 to 250 by 50) offset=(0,0);
ods html body="country_body.html" gtitle gfootnote path=odsout style=listing;
options nobyline;
%macro do_country(country);
ods html anchor="&country";
title1 ls=1.5 "Breakdown for #byval(country)"; title2 "(In Millions of Metric Tons)";
proc gchart data=newgrain (where=(country="&country"));
format country $country.;
by country; /* Enables the use of #byval() in title and description */
vbar year / discrete type=sum sumvar=megtons
group=type
subgroup=year
legend=legend1
outside=sum
space=0
maxis=axis1
raxis=axis6
gaxis=axis5
autoref cref=graydd clipref
html=typedrill
html_legend=yeardrill
name="country_&country"
des="Grain and Year Breakdown for #byval(country)";
run;
%mend do_country;
%do_country(CHN); %do_country(USA); %do_country(IND); %do_country(INS); %do_country(BRZ); quit;
proc gchart data=newgrain (where=(country="&country"));
format country $country.;
by country; /* Enables the use of #byval() in title and description */
vbar year / discrete type=sum sumvar=megtons
group=type
subgroup=year
legend=legend1
outside=sum
space=0
maxis=axis1
raxis=axis6
gaxis=axis5
autoref cref=graydd clipref
html=typedrill
html_legend=yeardrill
name="country_&country"
des="Grain and Year Breakdown for #byval(country)";
run;
%macro do_type(type);
ods html body="&type._body.html" newfile=table gtitle gfootnote path=odsout style=listing;
%let minamount=30;
title1 ls=1.5 "Top Producers of &type"; title2 "(Producing &minamount Million Metric Tons or More)";
/* Produce the series of bar charts: country and type. */
proc gchart data=newgrain (where=(megtons ge &minamount and type="&type"));
format country $country.;
vbar year / discrete type=sum sumvar=megtons
group=country
subgroup=year
legend=legend1
outside=sum
space=0
maxis=axis1
raxis=axis6
gaxis=axis5
autoref cref=graydd clipref
html=countrydrill
html_legend=yeardrill
name="type_&type"
des="Top &type Producers (&minamount Million Metric Tons or More)";
run;
quit;
%mend do_type;
%do_type(Corn); %do_type(Rice); %do_type(Wheat);
title; footnote;
ods html close; ods html;
title1 ls=1.5 "Top Producers of &type"; title2 "(Producing &minamount Million Metric Tons or More)";
/* Produce the series of bar charts: country and type. */
proc gchart data=newgrain (where=(megtons ge &minamount and type="&type"));
format country $country.;
vbar year / discrete type=sum sumvar=megtons
group=country
subgroup=year
legend=legend1
outside=sum
space=0
maxis=axis1
raxis=axis6
gaxis=axis5
autoref cref=graydd clipref
html=countrydrill
html_legend=yeardrill
name="type_&type"
des="Top &type Producers (&minamount Million Metric Tons or More)";
run;
quit;
| Features: |
VBAR3D Statement
|
| Other features: |
|

/* Create the temporary data set named sales. */ data sales; length Region $ 4 State $ 2; format Sales dollar8.; input Region State Sales Year Qtr; datalines; West CA 13636 1999 1 West OR 18988 1999 1 West CA 14523 1999 2 West OR 18988 1999 2 East MA 18038 1999 1 East NC 13611 1999 1 East MA 11084 1999 2 East NC 19660 1999 2 West CA 12536 1998 1 West OR 17888 1998 1 West CA 15623 1998 2 West OR 17963 1998 2 East NC 17638 1998 1 East MA 12811 1998 1 East NC 12184 1998 2 East MA 12760 1998 2 ; /* Specify the JAVA device for generating the chart. */ goptions reset=all border device=java; /* Close the current ODS HTML destination. */ ods html close; /* Open the HTML destination. Specify vbarweb.htm as */ /* the output filename and GEARS as the style. */ ods html file="vbarweb.htm" style=listing; /* Generate the bar chart. Group by YEAR and subgroup */ /* by STATE. */ title "Company Sales, Mid Year"; proc gchart data=sales; vbar3d region / sumvar=sales group=year subgroup=state; run; quit; /* ODS html to close the output file, and then reopen ODS HTML. */ ods html close; ods html;
| Features: |
VBAR statement
GREPLAY DELETE statement |
| Other features: |
BY-Group processing
OPTIONS statement NOBYLINE option |

filename gout ".";
data regsales(drop=drillurl imgurl);
length Region State $8 drillurl imgurl $50 htmlstr $256;
format Sales dollar8.;
input Region State Sales drillurl imgurl;
/* Create and add the HTML variable for each observation. */
htmlstr="href="||quote(trim(drillurl))||
" title="||quote(trim(Region)||" Region") ||
" ONMOUSEOVER=ShowImage("||quote(trim(imgurl))||
",400,25,200,200); changeOpacity(.5)";
datalines;
Central IL 18038 ./regsales.html#rpt ./sales.svg
Central IN 13611 ./regsales.html#rpt ./sales.svg
Central OH 11084 ./regsales.html#rpt ./sales.svg
Central MI 19660 ./regsales.html#rpt ./sales.svg
South FL 14541 ./regsales.html#rpt1 ./sales1.svg
South GA 19022 ./regsales.html#rpt1 ./sales1.svg
West CA 13636 ./regsales.html#rpt2 ./sales2.svg
West OR 18988 ./regsales.html#rpt2 ./sales2.svg
West WA 14523 ./regsales.html#rpt2 ./sales2.svg
;
goptions reset=all border device=svg xpixels=600 ypixels=450;
ods html close;
ods html body="salesreport.html" path=gout style=listing
parameters=("drilldownmode"="html");
title1 "Company Sales"; footnote1 j=c "Click bar to view an enlarged region graph."; proc gchart data=regsales; vbar region / sumvar=sales width=8 patternid=midpoint html=htmlstr; /* Set the HTML variable to htmlstr. */ run; quit;
ods html close;
proc greplay nofs igout=work.gseg; delete _all_; run; quit;
goptions reset=all border device=svgt;
options nobyline;
ods html body="regsales.html" path=gout anchor="rpt" style=listing;
title "#byval(region) Region Sales"; proc gchart data=regsales; vbar state / sumvar=sales width=10 name="sales" patternid=midpoint; by region; run; quit;
ods html close; ods html;
data regsales(drop=drillurl imgurl);
length Region State $8 drillurl imgurl $50 htmlstr $256;
format Sales dollar8.;
input Region State Sales drillurl imgurl;
/* Create and add the HTML variable for each observation. */
htmlstr="href="||quote(trim(drillurl))||
" title="||quote(trim(Region)||" Region") ||
" ONMOUSEOVER=ShowImage("||quote(trim(imgurl))||
",400,25,200,200); changeOpacity(.5)";
datalines;
Central IL 18038 ./regsales.html#rpt ./sales.svg
Central IN 13611 ./regsales.html#rpt ./sales.svg
Central OH 11084 ./regsales.html#rpt ./sales.svg
Central MI 19660 ./regsales.html#rpt ./sales.svg
South FL 14541 ./regsales.html#rpt1 ./sales1.svg
South GA 19022 ./regsales.html#rpt1 ./sales1.svg
West CA 13636 ./regsales.html#rpt2 ./sales2.svg
West OR 18988 ./regsales.html#rpt2 ./sales2.svg
West WA 14523 ./regsales.html#rpt2 ./sales2.svg
;title1 "Company Sales"; footnote1 j=c "Click bar to view an enlarged region graph."; proc gchart data=regsales; vbar region / sumvar=sales width=8 patternid=midpoint html=htmlstr; /* Set the HTML variable to htmlstr. */ run; quit;