Sample 24889: Control the width of bars based on a variable
/* The Annotate facility is used to draw the bars of the */
/* vertical bar chart. The GCHART procedure is used to */
/* produce the midpoint and response axes. */
/* Set graphics options */
goptions reset=all border;
/* Create input data set, A */
data a;
input xvar yvar size_var colors $;
datalines;
5 10 5 blue
10 20 10 green
15 30 20 red
;
/* Create the annotate data set, ANNO. */
data anno;
length color function style $8;
retain xsys '2' when 'a';
set a;
color=put(colors,8.);
function='move'; xsys='2'; x=xvar; ysys='1'; y=0; output;
function='move'; xsys='7'; x=-1*(size_var/2); output;
/* The BAR function is used to draw a fillable rectangle whose */
/* lower-left corner is defined by the internal variables */
/* (XLAST,YLAST) and whose upper-right corner is defined by the */
/* (X,Y) variable pair. */
function='bar'; line=0; style='solid';
x=-1*x*2; ysys='2'; y=yvar; output;
run;
proc print;
run;
/* Add the footnotes */
footnote f=swiss c=black 'Legend ' c=blue f=marker 'U'
f=swiss c=black ' Val-1 ' c=green f=marker 'U'
f=swiss c=black ' Val-2 ' c=red f=marker 'U'
f=swiss c=black ' Val-3 ';
/* Define empty pattern for the bars. The color of the bars */
/* will be the same as the background color of the graph so */
/* that the bars will not be visible. */
pattern v=empty c=white r=3;
/* Add the titles */
title1 h=1.5 'Width Based on DS Variable';
/* Define axis characteristics */
axis1 order=(5 to 15 by 5) offset=(5,5)pct minor=none width=2;
axis2 order=(0 to 50 by 10) minor=none width=2;
/* Produce the chart */
proc gchart data=a;
vbar xvar / sumvar=yvar discrete anno=anno
maxis=axis1 raxis=axis2;
run;
quit;

The Annotate facility is used to draw the bars of the
vertical bar chart. The GCHART procedure is used to
produce the midpoint and response axes.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Patterns
|
| Date Modified: | 2005-08-24 16:06:29 |
| Date Created: | 2004-11-11 11:07:55 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |