This sample uses the Graph Template Language (GTL) to produce a series of grouped overlay bar charts. It features the DISCRETEOFFSET option which is available beginning in SAS 9.2 TS2M3.
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.
data revenue;
input Year A B C;
format A B C D dollar.;
D=1.5*(a+b+c)/3;
datalines;
2005 5000 4500 4300
2006 4000 3800 3600
2007 3800 3300 3200
2008 5000 4200 3800
;
run;
title;
proc template;
define statgraph DiscreteOffsetBar;
begingraph;
entrytitle 'Bar Charts with Varying Widths and Discrete Offsets';
layout lattice / columns=3 rowdatarange=union;
rowaxes;
rowaxis / display=(line ticks tickvalues);
rowaxis / display=(line ticks tickvalues);
endrowaxes;
layout overlay / yaxisopts=(label='Revenue' offsetmax=0.15)
xaxisopts=(display=(line ticks tickvalues)) cycleattrs=true;
barchartparm x=year y=d / skin=modern barwidth=0.9 name='d' datatransparency=0.3;
barchartparm x=year y=a / skin=modern discreteoffset=-0.2 barwidth=0.4 name='a';
barchartparm x=year y=b / skin=modern discreteoffset=0 barwidth=0.4 name='b';
barchartparm x=year y=c / skin=modern discreteoffset=0.2 barwidth=0.4 name='c';
referenceline x='2008' / discreteoffset=-0.5 lineattrs=(thickness=1 pattern=longdash);
endlayout;
layout overlay / yaxisopts=(label='Revenue' offsetmax=0.15)
xaxisopts=(display=(line ticks tickvalues)) cycleattrs=true;
barchartparm x=year y=d / skin=modern barwidth=0.9 name='d' datatransparency=0.3;
barchartparm x=year y=a / skin=modern discreteoffset=-0.3 barwidth=0.3;
barchartparm x=year y=b / skin=modern discreteoffset=0 barwidth=0.3;
barchartparm x=year y=c / skin=modern discreteoffset=0.3 barwidth=0.3;
referenceline x='2008' / discreteoffset=-0.5 lineattrs=(thickness=1 pattern=longdash);
endlayout;
layout overlay / yaxisopts=(label='Revenue' offsetmax=0.15)
xaxisopts=(display=(line ticks tickvalues)) cycleattrs=true;
barchartparm x=year y=d / skin=modern barwidth=0.9 name='d' datatransparency=0.3;
barchartparm x=year y=a / skin=modern discreteoffset=-0.3 barwidth=0.24;
barchartparm x=year y=b / skin=modern discreteoffset=0 barwidth=0.24;
barchartparm x=year y=c / skin=modern discreteoffset=0.3 barwidth=0.24;
referenceline x='2008' / discreteoffset=-0.5 lineattrs=(thickness=1 pattern=longdash);
endlayout;
sidebar / align=bottom spacefill=false;
discretelegend 'a' 'b' 'c' 'd' / title='Product:';
endsidebar;
endlayout;
endgraph;
end;
run;
ods listing close;
ods html style=curve image_dpi=100 file='discreteoffset.html' path='.';
ods graphics / reset noborder width=600px height=400px
imagename='DiscreteOffsetBar' imagefmt=gif noscale;
proc sgrender data=revenue template=DiscreteOffsetBar;
run;
ods html close;
ods listing;
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 ==> SGRENDER Query and Reporting ==> Creating Reports ==> Graphical ==> Financial Industry Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Template Language (GTL) |
Date Modified: | 2010-06-16 16:14:58 |
Date Created: | 2010-03-24 14:33:43 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9.2 TS2M3 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS2M3 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS2M3 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS2M3 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS2M3 | |||
Microsoft® Windows® for x64 | 9.2 TS2M3 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS2M3 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS2M3 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS2M3 | |||
Microsoft Windows Server 2008 | 9.2 TS2M3 | |||
Microsoft Windows XP Professional | 9.2 TS2M3 | |||
Windows 7 Enterprise 32 bit | 9.2 TS2M3 | |||
Windows 7 Enterprise x64 | 9.2 TS2M3 | |||
Windows 7 Home Premium 32 bit | 9.2 TS2M3 | |||
Windows 7 Home Premium x64 | 9.2 TS2M3 | |||
Windows 7 Professional 32 bit | 9.2 TS2M3 | |||
Windows 7 Professional x64 | 9.2 TS2M3 | |||
Windows 7 Ultimate 32 bit | 9.2 TS2M3 | |||
Windows 7 Ultimate x64 | 9.2 TS2M3 | |||
Windows Vista | 9.2 TS2M3 | |||
64-bit Enabled AIX | 9.2 TS2M3 | |||
64-bit Enabled HP-UX | 9.2 TS2M3 | |||
64-bit Enabled Solaris | 9.2 TS2M3 | |||
HP-UX IPF | 9.2 TS2M3 | |||
Linux | 9.2 TS2M3 | |||
Linux for x64 | 9.2 TS2M3 | |||
OpenVMS on HP Integrity | 9.2 TS2M3 | |||
Solaris for x64 | 9.2 TS2M3 |