Sample 25558: Label the states on a U.S. map using PROC GMAP
This program uses an Annotate data set with PROC GMAP to display the state abbreviation in the center of each state.
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 program uses an Annotate data set with PROC GMAP to display the state abbreviation in the center of each state.
The graphics output in the Results tab was produced using SAS® 9.4. Submitting the sample code with releases of SAS prior to SAS 9.4 might produce different results.
/* Set the graphics environment */
goptions reset=all border cback=white htitle=13pt;
/* Create data set CENTER */
data center;
length function $ 8;
retain flag 0 xsys ysys '2' hsys '3' when 'a';
set maps.uscenter
(where=(fipstate(state) ne 'DC')
drop=long lat);
style = "'Albany AMT/bold'";
function='label';
text=fipstate(state);
size=2.5;
position='5';
if ocean='Y' then
do;
position='6';
output;
function='move';
flag=1;
end;
else if flag=1 then
do;
function='draw';
size=.25;
flag=0;
end;
output;
run;
/* Define a title for the map */
title 'Positioning State Labels with MAPS.USCENTER';
/* Create sample map response data */
/* Your response data would be used instead of this step */
data states;
/* create the STATE variable to match the STATE
variable in the map data set */
do state=1 to 56, 72;
/* assign a random value for the response variable */
value=int(ranuni(123)*100);
/* remove values that are not valid state FIPS codes */
if state not in (3 7 14 43 52) then output;
end;
run;
/* Display the choropleth map */
proc gmap data=states map=maps.us;
id state;
choro value / annotate=center;
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 program uses an Annotate data set with PROC GMAP to display the state abbreviation in the center of each state.
Type: | Sample |
Topic: | Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation SAS Reference ==> Procedures ==> GMAP
|
Date Modified: | 2005-08-27 03:03:23 |
Date Created: | 2005-05-23 14:15:27 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9 TS M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9 TS M0 | |
Microsoft Windows 2000 Advanced Server | 9 TS M0 | |
Microsoft Windows 2000 Datacenter Server | 9 TS M0 | |
Microsoft Windows 2000 Server | 9 TS M0 | |
Microsoft Windows 2000 Professional | 9 TS M0 | |
Microsoft Windows NT Workstation | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Standard Edition | 9 TS M0 | |
Microsoft Windows XP Professional | 9 TS M0 | |
64-bit Enabled AIX | 9 TS M0 | |
64-bit Enabled HP-UX | 9 TS M0 | |
64-bit Enabled Solaris | 9 TS M0 | |
HP-UX IPF | 9 TS M0 | |
Linux | 9 TS M0 | |
OpenVMS Alpha | 9 TS M0 | |
Tru64 UNIX | 9 TS M0 | |