The sample code on the Full Code tab uses the Annotate facility to draw lines connecting the midpoints across groups on a bar chart generated with the GCHART procedure.
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.
/* Set the graphics environment */
goptions reset=all border cback=white htitle=12pt htext=10pt;
/* Create sample data set */
data test;
do Groupvar=1 to 5 by 1;
do Midvar='XX','YY';
Yvar=ranuni(10)*25;
output;
end;
end;
run;
/* Draw the line connecting values for the first midpoint */
data annoline1;
length function style color $8;
retain xsys ysys '2' when 'a';
set test;
if groupvar=1 and midvar='XX' then do;
function='move';
midpoint=midvar;
y=yvar;
color='vibg';
group=groupvar;
output;
function='symbol';
size=1;
style='marker';
text='P';
output;
end;
else if midvar='XX' then do;
function='draw';
midpoint=midvar;
y=yvar;
color='vibg';
group=groupvar;
output;
function='symbol';
size=1;
style='marker';
text='P';
output;
end;
run;
/* Draw the line connecting values for the second midpoint */
data annoline2;
length function style color $8;
retain xsys ysys '2' when 'a';
set test;
if groupvar=1 and midvar='YY' then do;
function='move';
midpoint=midvar;
y=yvar;
color='black';
group=groupvar;
output;
function='symbol';
size=1;
style='marker';
text='P';
output;
end;
else if midvar='YY' then do;
function='draw';
midpoint=midvar;
y=yvar;
color='black';
group=groupvar;
output;
function='symbol';
size=1;
style='marker';
text='P';
output;
end;
run;
/* Combine the two annotate data sets */
data allanno;
set annoline1 annoline2;
run;
/* Define a title for the graph */
title1 'Connect Midpoints Across Groups';
/* Define response axis characteristics */
axis1 label=(angle=90 'Yvar');
proc gchart data=test;
vbar midvar / discrete sumvar=yvar group=groupvar
annotate=allanno width=8 space=0
patternid=midpoint raxis=axis1;
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.
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: | 2011-10-18 11:44:48 |
Date Created: | 2011-07-29 15:17:19 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |