Sample 24893: Annotate selected state capitals with PROC GMAP
This program uses PROC GMAP to annotate a star and the name of the city at the locations of the state capitals for South Carolina, North Carolina, and Virginia.
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 PROC GMAP to annotate a star and the name of the city at the locations of the state capitals for South Carolina, North Carolina, and Virginia.
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 an annotate data set for the cities */
data cities;
length text $ 20 color $ 8 style $ 25;
/* Get city coordinates from the MAPS.USCITY data set */
set maps.uscity(keep=state long lat city capital);
/* Subset South Carolina, North Carolina and Virginia */
/* Only label the state capital */
where state in (37 45 51) and capital='Y';
/* Convert degrees to radians */
x=(atan(1)/45)*long;
y=(atan(1)/45)*lat;
/* Set a flag to identify the annotate observations */
flag=1;
/* Coordinate system is data values */
xsys = '2';
ysys = '2';
/* Annotate is applied after the procedure output */
when = 'A';
/* Create an observation to label the X,Y */
/* coordinate with a colored star. */
function='label';
style='special';
text='M';
color='depk';
position='5';
size=2.5;
output;
/* Create an oberservation to label the X,Y coordinate */
/* with the name of the state capital city. */
function='label';
style="'Albany AMT/bold'";
text=city;
color='grp';
position='2';
size=1.5;
output;
drop capital;
run;
/* Combine the annotate data set with the unprojected map */
/* data set to be projected together. */
data all;
/* Subset the map data for only the desired states */
set maps.states(where=(state in(37 45 51))) cities;
run;
/* Project the maps. ASIS permits duplicate observations to */
/* exist in the data and should be used whenever Annotate */
/* observations are included in a projection. */
proc gproject data=all out=allp asis ;
id state;
run;
quit;
/* Separate the projected data back into two distinct data sets. */
/* FLAG = 1 designates the observation is an annotate observation */
data map anno;
set allp;
if flag=1 then output anno;
else output map;
run;
title1 'Selected State Capitals';
/* Produce the new map with annotation. */
proc gmap data=map map=map;
id state;
choro state / anno=anno discrete nolegend;
pattern1 r=150 v=e c=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 program uses PROC GMAP to annotate a star and the name of the city at the locations of the state capitals for South Carolina, North Carolina, and Virginia.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation
|
Date Modified: | 2005-08-24 16:06:30 |
Date Created: | 2004-11-11 11:07:56 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |