Sample 40502: Annotate a pie chart in selected states with PROC GMAP
This sample uses PROC GMAP with the Annotate facility to display a pie chart in selected states on a map.
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 PROC GMAP with the Annotate facility to display a pie chart in selected states on a map.
The graphics output in the Results tab was produced using SAS® 9.2. Submitting
the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Create sample data for two vendors */
data shares;
input State Vendor Num;
datalines;
12 1 98
12 2 23
13 1 34
13 2 45
37 1 12
37 2 56
45 1 89
45 2 75
51 1 12
51 2 34
;
run;
/* Calculate the values for the pie */
proc freq data=shares noprint;
weight num;
tables state*vendor / outpct out=freq;
run;
/* Create an annotate data set to */
/* draw a pie chart in each state */
data anno;
/* Get the coordinates for the center of the
state from the MAPS.USCENTER data set */
merge freq(in=a) maps.uscenter;
by state;
if a;
/* X and Y coordinate system is set to data values */
xsys='2';
ysys='2';
/* Apply the annotation after the procedure output */
when='a';
/* Draw a pie */
function='pie';
/* Color the slices for each vendor */
if vendor=1 then color='CX7C95CA';
else color='CXDE7E6F';
/* Draw the portion of the pie */
rotate=360*pct_row/100;
size=2;
/* Use a solid pattern fill */
style='solid';
line=0;
run;
pattern1 v=me c=black r=5;
title 'Annotate a pie chart within each state';
/* Generate the map and apply the annotation */
proc gmap data=maps.us(where=(state in(12 13 37 45 51)))
map=maps.us(where=(state in(12 13 37 45 51)));
id state;
choro state / nolegend annotate=anno coutline=black;
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.
This sample uses PROC GMAP with the Annotate facility to display a pie chart in selected states on a map.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation
|
Date Modified: | 2010-10-22 10:53:43 |
Date Created: | 2010-08-03 11:28:07 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |