Sample 35135: Horizontal Bar Chart with Table Information
This example uses the Graph Template Language (GTL) to produce a horizontal bar chart with a table to the left of the bar chart. The graph uses a four-column lattice layout, where the rightmost cell has a labeled bar chart with an embedded table.
This example uses the Graph Template Language (GTL) to produce a horizontal bar chart with a table to the left of the bar chart. The graph uses a four-column lattice layout, where the rightmost cell has a labeled bar chart with an embedded table.
proc template;
define statgraph BarTableHorz;
mvar T1 T2 T3 T4 T5 T6 T7 T8 T9 P1 P2 P3 P4 P5 P6 P7 P8 P9;
begingraph / designwidth=600px designheight=400px;
entrytitle "Professional Golf Statistics for 2007";
layout lattice / columns=4 columngutter=2
columnweights=(.05 .05 .05 .85);
column2headers;
entry halign=right "Age" / textattrs=(size=7pt weight=bold);
entry halign=right "Events" / textattrs=(size=7pt weight=bold);
entry halign=right "Wins" / textattrs=(size=7pt weight=bold);
endcolumn2headers;
/* columns to left of barchart */
layout overlay / walldisplay=none border=false
yaxisopts=(reverse=true type=discrete display=none)
xaxisopts=(display=none offsetmin=0.3 offsetmax=0);
scatterplot y=player x=constant / markercharacter=age markerattrs=(size=0);
endlayout;
layout overlay / walldisplay=none border=false
yaxisopts=(reverse=true type=discrete display=none)
xaxisopts=(display=none offsetmin=.3 offsetmax=0);
scatterplot y=player x=constant / markercharacter=events markerattrs=(size=0);
endlayout;
layout overlay / walldisplay=none border=false
yaxisopts=(reverse=true type=discrete display=none)
xaxisopts=(display=none offsetmin=.3 offsetmax=0);
scatterplot y=player x=constant / markercharacter=wins markerattrs=(size=0);
endlayout;
/* barchart with inset */
layout overlay / yaxisopts=(reverse=true display=(tickvalues) tickvalueattrs=(weight=bold))
xaxisopts=(griddisplay=on labelattrs=(weight=bold)
linearopts=(tickvalueformat=(extractscale=true)) );
/* inset */
layout gridded / valign=bottom halign=right border=true opaque=true;
entry "Tiger's 2007 Wins" / textattrs=(weight=bold);
layout gridded /columns=2 ;
entry halign=left T1; entry halign=right P1;
entry halign=left T2; entry halign=right P2;
entry halign=left T3; entry halign=right P3;
entry halign=left T4; entry halign=right P4;
entry halign=left T5; entry halign=right P5;
entry halign=left T6; entry halign=right P6;
entry halign=left T7; entry halign=right P7;
endlayout;
endlayout;
barchart x=player y=Earnings / barlabel=true barlabelformat=dollar12. orient=horizontal
skin=modern outlineattrs=(color=black);
endlayout;
endlayout;
endgraph;
end;
run;
title;
data PGA2007;
input Rank 2. Player & $15. Age Events Rounds CutsMade Top10 Wins Earnings;
retain Constant 1;
label CutsMade="Cuts Made" Top10="Top 10s";
format Earnings dollar12.;
format age events wins 3.0;
datalines;
1 Tiger Woods 33 16 61 16 12 7 10867052
2 Phil Mickelson 38 22 73 16 7 3 5819988
3 Vijay Singh 45 27 101 25 7 2 4728377
4 Steve Stricker 41 23 80 19 9 1 4663077
5 K.J. Choi 38 25 88 20 7 2 4587859
6 Rory Sabbatini 32 23 80 18 10 1 4550040
7 Jim Furyk 38 24 84 20 8 1 4154046
8 Zach Johnson 32 23 78 18 5 2 3922338
9 Sergio Garcia 29 19 67 16 7 0 3721185
10 Aaron Baddeley 27 23 82 19 7 1 3441119
run;
data TigerWins;
input Tournament $1-17 Purse : comma12.;
call symput(cats("T",_n_),strip(Tournament));
call symput(cats("P",_n_),put(Purse,dollar11.));
datalines;
Tour Championship $1,260,000
BMW Championship $1,260,000
PGA Championship $1,350,000
WGC: Bridgestone $1,350,000
Wachovia $1,134,000
WGC: CA $1,350,000
Buick Inv. $936,000
run;
proc template;
define Style BarTableHorzStyle;
parent = styles.seaside;
style GraphFonts from GraphFonts
"Fonts used in graph styles" /
'GraphTitleFont' = (", ",10pt,bold)
'GraphFootnoteFont' = (", ",8pt)
'GraphLabelFont' = (", ",8pt)
'GraphValueFont' = (", ",7pt)
'GraphDataFont' = (", ",7pt);
end;
run;
ods listing close;
ods html file="BarTableHorz.html" path='.' style=BarTableHorzStyle image_dpi=100;
ods graphics / reset imagename='BarTableHorz' imagefmt=gif;
proc sgrender data=PGA2007 template=BarTableHorz;
run;
ods html close;
ods listing;
This example uses the Graph Template Language (GTL) to produce a horizontal bar chart with a table to the left of the bar chart.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> SGRENDER Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Template Language (GTL)
|
| Date Modified: | 2009-03-19 09:20:05 |
| Date Created: | 2009-03-16 10:47:13 |
Operating System and Release Information
| SAS System | SAS/GRAPH | z/OS | 9.2 TS2M0 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS2M0 | |
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS2M0 | |
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS2M0 | |
| Microsoft Windows XP 64-bit Edition | 9.2 TS2M0 | |
| Microsoft® Windows® for x64 | 9.2 TS2M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS2M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS2M0 | |
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS2M0 | |
| Microsoft Windows XP Professional | 9.2 TS2M0 | |
| Windows Vista | 9.2 TS2M0 | |
| 64-bit Enabled AIX | 9.2 TS2M0 | |
| 64-bit Enabled HP-UX | 9.2 TS2M0 | |
| 64-bit Enabled Solaris | 9.2 TS2M0 | |
| HP-UX IPF | 9.2 TS2M0 | |
| Linux | 9.2 TS2M0 | |
| Linux for x64 | 9.2 TS2M0 | |
| OpenVMS on HP Integrity | 9.2 TS2M0 | |
| Solaris for x64 | 9.2 TS2M0 | |