Sample 44735: Define bar fill colors with an attribute map with the Graph Template Language (GTL)
This sample uses the SAS® 9.3 DISCRETEATTRMAP block and the DISCRETEATTRVAR statement in the Graph Template Language (GTL) to define the color of the bars.
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 the SAS® 9.3 DISCRETEATTRMAP block and the DISCRETEATTRVAR statement in the Graph Template Language (GTL) to define the color of the bars.
title;
footnote;
data totals;
length dept $ 7 Site $ 8;
input dept Site Quarter Sales;
datalines;
Parts Sydney 1 7043.97
Parts Atlanta 1 8225.26
Tools Paris 4 1775.74
Tools Atlanta 4 3424.19
Repairs Sydney 2 5543.97
Repairs Paris 3 6914.25
;
run;
proc template;
define statgraph barcolors;
begingraph;
entrytitle 'Using an Attribute Map to Assign Fill Colors';
/* Define the attribute map and assign the name 'colors' */
discreteattrmap name='colors' / ignorecase=true;
value "Parts" / fillattrs=(color=vigb);
value "Tools" / fillattrs=(color=purple);
value "Repairs" / fillattrs=(color=cxff8000);
enddiscreteattrmap;
/* Associate the attribute map with input data column DEPT */
/* and assign the name DEPTCOLORS to the named association */
discreteattrvar attrvar=deptcolors var=dept attrmap='colors';
/* Reference DEPTCOLORS in the BARCHART statement */
layout overlay;
barchart x=Site y=Sales / group=deptcolors groupdisplay=cluster name='dept'
dataskin=pressed barlabel=true;
discretelegend 'dept';
endlayout;
endgraph;
end;
run;
ods graphics / height=400px width=600px;
proc sgrender data=totals template=barcolors;
run;
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 the SAS® 9.3 DISCRETEATTRMAP block and the DISCRETEATTRVAR statement in the Graph Template Language (GTL) to define the color of the bars.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGRENDER
|
Date Modified: | 2011-11-03 10:56:01 |
Date Created: | 2011-10-26 15:31:42 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.3 TS1M0 | |
Z64 | 9.3 TS1M0 | |
Microsoft® Windows® for x64 | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M0 | |
Microsoft Windows Server 2008 | 9.3 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M0 | |
Microsoft Windows XP Professional | 9.3 TS1M0 | |
Windows 7 Enterprise 32 bit | 9.3 TS1M0 | |
Windows 7 Enterprise x64 | 9.3 TS1M0 | |
Windows 7 Home Premium 32 bit | 9.3 TS1M0 | |
Windows 7 Home Premium x64 | 9.3 TS1M0 | |
Windows 7 Professional 32 bit | 9.3 TS1M0 | |
Windows 7 Professional x64 | 9.3 TS1M0 | |
Windows 7 Ultimate 32 bit | 9.3 TS1M0 | |
Windows 7 Ultimate x64 | 9.3 TS1M0 | |
Windows Vista | 9.3 TS1M0 | |
Windows Vista for x64 | 9.3 TS1M0 | |
64-bit Enabled AIX | 9.3 TS1M0 | |
64-bit Enabled HP-UX | 9.3 TS1M0 | |
64-bit Enabled Solaris | 9.3 TS1M0 | |
HP-UX IPF | 9.3 TS1M0 | |
Linux | 9.3 TS1M0 | |
Linux for x64 | 9.3 TS1M0 | |
Solaris for x64 | 9.3 TS1M0 | |