Sample 24888: Use Annotation to add labeled reference lines to PROC GCHART output
This example uses the Annotate facility to add labeled reference lines to a vertical bar chart created with PROC GCHART.
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 code uses the Annotate facility to add labeled reference lines to a vertical bar chart created with PROC GCHART.
The graphics output in the Results tab was produced using SASĀ® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all border cback=white htitle=12pt;
/* Create input data set, A */
data a;
input Year Y;
datalines;
90 40
91 85
92 80
93 50
94 90
95 80
;
run;
/* Create the Annotate data set, B */
data b;
length color function $8 text $14;
retain xsys '1' ysys '2' when 'a';
function='move'; x=0; y=60; output;
function='draw'; x=100; y=60;
color='blue'; size=2; output;
function='label'; x=50; y=60; size=1.5;
position='2'; color='black'; text='Goal=60'; output;
function='move'; x=0; y=70.83; output;
function='draw'; x=100; y=70.83;
color='green'; size=2; output;
function='label'; x=50; y=70.83; size=1.5;
position='2'; color='black'; text='Avg=70.83'; output;
run;
/* Add a title to the graph */
title1 'Sales Report';
/* Define axis characteristics */
axis1 order=(0 to 100 by 25);
/* Produce the bar chart using the ANNO= */
/* option on the VBAR statement */
proc gchart data=a;
vbar year / anno=b sumvar=y raxis=axis1 discrete
width=8;
run;
quit;
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 example uses the Annotate facility to add labeled reference lines to a vertical bar chart created with PROC GCHART.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Bar
|
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 |