Sample 24893: Annotate selected state capitals
/*********************************************************/
/* This program will annotate a star and the name of the */
/* city at the locations of the state capitals for */
/* South Carolina, North Carolina, and Virginia. */
/*********************************************************/
goptions reset=all;
title h=2 'Selected State Capitals';
/* Create an annotate data set for the cities */
data cities;
length text $20. color $8.;
/* 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 green colored star */
function='label';
style='special';
text='M';
color='green';
position='5';
size=1.5;
output;
/* Create an oberservation to label the x,y coordinate */
/* with the name of the state capital city. */
function='label';
style='swiss';
text=city;
color='blue';
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;
/* 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=red;
run;
quit;
This program will 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 ==> Labels
|
| 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 |