The sample code on the Full Code tab uses PROC GCHART with an Annotate data set to create a connected data table beneath a bar graph.
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 cback=white border htitle=12pt htext=10pt;
data ds1;
input year $ exp rev;
datalines;
1997/98 302.3 310.8
1998/99 323.0 328.7
1999/00 354.4 363.5
2000/01 381.7 390.2
2001/02 426.8 429.1
;
run;
data ds2;
set ds1;
n=_n_;
run;
data _null_;
set ds2 end=eof;
if eof then call symput('skip',left(n));
run;
data ds2;
set ds2;
resp=exp; mid='exp'; output;
resp=rev; mid='rev'; output;
run;
proc sort;
by year mid;
run;
data anno;
set ds2;
by year mid;
length function color $8 text $20 style $ 20;
/* Populate the table */
if first.year then do;
function='move'; xsys='2'; ysys='1';
midpoint=mid; group=year; y=0;
output;
function='cntl2txt'; output;
function='label'; xsys='A'; ysys='3';
x=+4; y=13;
text=trim(left(put(exp,8.1)));
color='black'; position='+'; when='a';
output;
function='move'; xsys='2'; ysys='1';
midpoint=mid; group=year; y=0;
output;
function='cntl2txt'; output;
function='label'; xsys='A'; ysys='3';
x=+4; y=9;
text=trim(left(put(rev,8.1)));
color='black'; position='+'; when='a';
output;
end;
/* Generate the table frame */
function='move'; xsys='3'; ysys='3';
x=3; y=6;
output;
function='bar'; xsys='1'; ysys='3';
x=100; y=15;
style='empty'; color='black'; line=0;
output;
/* Generate the row headers */
function='label'; xsys='3'; ysys='3';
style='marker'; text='U'; color='cx7c95ca';
x=4; y=13; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='"Albany AMT"'; text='Expenditure'; color='black';
x=7; y=13; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='marker'; text='U'; color='cxde7e6f';
x=4; y=8.5; position='6';
output;
function='label'; xsys='3'; ysys='3';
style='"Albany AMT"'; text='Revenue'; color='black';
x=7; y=9; position='6';
output;
/* Generate the vertical lines in the table */
function='move'; xsys='1'; ysys='1';
x=0; y=0;
output;
function='draw'; xsys='1'; ysys='3';
x=0; y=6;
line=1; color='black';
output;
function='move'; xsys='1'; ysys='1';
x=100; y=0;
output;
function='draw'; xsys='1'; ysys='3';
x=100; y=6;
line=1; color='black';
output;
if first.year and n ^=&skip then do;
function='move'; xsys='2'; ysys='1';
midpoint=mid; y=0; group=year;
output;
function='move'; xsys='A'; ysys='1';
x=+15.5; x=+12; y=0;
output;
function='draw'; xsys='A'; ysys='3';
x=+0; y=6;
color='black'; line=1;
output;
end;
/* Generate the horizontal line in the table */
function='move'; xsys='3'; ysys='3';
x=3; y=10.5;
output;
function='draw'; xsys='1'; ysys='3';
x=100; y=10.5;
line=1; color='black';
output;
run;
title1 'Revenue and Expenditures, 1997/98-2001-02';
axis1 label=(a=90 'Millions of Dollars')
order=(100 to 450 by 50)
minor=none;
axis2 label=none
value=none
origin=(20pct,22pct)
offset=(4pct,4pct);
axis3 label=none;
footnote1 'Fiscal Year';
footnote2 h=.5 ' ';
pattern1 value=solid color=cx7c95ca;
pattern2 value=solid color=cxde7e6f;
proc gchart data=ds2;
vbar mid / sumvar=resp group=year
coutline=black patternid=midpoint
space=0 gspace=5 width=4
cframe=ltgray autoref clipref
raxis=axis1 maxis=axis2 gaxis=axis3
annotate=anno;
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: | 2009-05-18 14:55:34 |
Date Created: | 2009-05-01 17:19:20 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | Tru64 UNIX | 9.1 TS1M0 | |
OpenVMS Alpha | 9.1 TS1M0 | |||
Linux | 9.1 TS1M0 | |||
HP-UX IPF | 9.1 TS1M0 | |||
64-bit Enabled Solaris | 9.1 TS1M0 | |||
64-bit Enabled HP-UX | 9.1 TS1M0 | |||
64-bit Enabled AIX | 9.1 TS1M0 | |||
Microsoft Windows XP Professional | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | |||
Microsoft Windows NT Workstation | 9.1 TS1M0 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |||
Microsoft Windows 2000 Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | |||
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | |||
z/OS | 9.1 TS1M0 |