This sample uses PROC GCHART with the Annotate facility to display one standard deviation of the mean on a vertical bar chart. The Annotate data set is created using the statistics calculated by PROC MEANS.

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 PROC GCHART with the Annotate facility to display one standard deviation of the mean on a vertical bar chart. The Annotate data set is created using the statistics calculated by PROC MEANS.

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 cback=white border htitle=12pt htext=10pt;
data a;
input Mid_Var $ Resp_Var;
datalines;
AAA 5
AAA 4
AAA 7
BBB 7
BBB 6
BBB 9
CCC 4
CCC 3
CCC 6
DDD 5
DDD 4
DDD 7
;
run;
/* Use PROC MEANS to calculate the statistics */
/* needed to create the Annotate data set. */
proc means mean std data=a noprint;
by mid_var;
output out=b mean=mean std=std;
run;
/* Create the Annotate data set */
data anno;
length color function $8;
retain xsys ysys '2' hsys '4' when 'a' color 'depk' size 1;
set b;
/* Lower tick */
function='move'; xsys='2'; ysys='2';
midpoint=mid_var; y=mean-std;
output;
function='draw';
xsys='7'; ysys='2'; x=-2; y=mean-std;
output;
function='draw'; xsys='7'; ysys='2';
x=+4; y=mean-std;
output;
/* Upper tick */
function='move'; xsys='2'; ysys='2';
midpoint=mid_var; y=mean+std;
output;
function='draw'; xsys='7'; ysys='2';
x=-2; y=mean+std;
output;
function='draw'; xsys='7'; ysys='2';
x=+4; y=mean+std;
output;
/* Join upper and lower */
function='move'; xsys='2'; ysys='2';
midpoint=mid_var; y=mean-std;
output;
function='draw'; xsys='2'; ysys='2';
midpoint=mid_var; y=mean+std;
output;
run;
axis1 order=(0 to 10 by 5)
label=(angle=90 h=11pt 'Response Variable');
axis2 label=(h=11pt 'Midpoint Variable');
title1 'One Std of the Mean';
/* Create the graph using the ANNO= option */
/* on the VBAR statement. */
proc gchart data=a;
vbar mid_var / anno=anno raxis=axis1 maxis=axis2
type=mean sumvar=resp_var
width=10 space=4;
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 sample uses PROC GCHART with the Annotate facility to display one standard deviation of the mean on a vertical bar chart. The Annotate data set is created using the statistics calculated by PROC MEANS.

#### Operating System and Release Information

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:28 |

Date Created: | 2004-11-11 11:07:54 |

Product Family | Product | Host | SAS Release | |

Starting | Ending | |||

SAS System | SAS/GRAPH | All | n/a | n/a |