Chapter Contents


SAS/GRAPH Software: Reference

Example 1: Labeling Cities on a Map


Annotate function: LABEL
Annotate variables: HSYS
X and Y
Sample library member: GR10N01


This example labels a map of the continental United States with the location and names of three cities. The GMAP procedure draws a map of the U.S. and an Annotate data set adds the stars and labels.

The DATA step that creates the Annotate data set gets the x and y coordinates of the cities to be labeled from the MAPS.USCITY data set. Because MAPS.USCITY stores projected coordinates in the X and Y variables, the DATA step does not need to reassign the variable values. Also because X and Y contain data values (the map data set coordinates), the XSYS and YSYS variables specify coordinate system 2, absolute data values. However, the HSYS variable that controls text height uses coordinate system 3, percent of the graphics output area.

See Projecting an Annotate Data Set for an example of labeling a map using map coordinates in units of latitude and longitude.

See The GMAP Procedure for more information on using map data sets.

Note:   If the libref MAPS is automatically assigned at your site to the SAS data library containing the Institute-supplied map data sets, you can omit the LIBNAME statement.  [cautionend]

 Note about code
libname maps 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftext=swissb htitle=6 htext=3;
 Note about code
data lower48;
   if state ne stfips('AK');
   if state ne stfips('HI');
 Note about code
data citystar;
   length function style color $ 8 position $ 1
          text $ 20;
   retain function 'label' xsys ysys '2' hsys '3'
          when 'a';
 Note about code
   set maps.uscity(keep=x y city state);
   if (city='Atlanta' and state=13)
       or city='Chicago'
       or city='Seattle';
 Note about code
   style='special'; text='M'; color='red'; size=7;
      position='5'; output;
 Note about code
   style='swissb'; text=city; color='green';
      size=5; position='8'; output;
 Note about code
title 'Distribution Center Locations';
footnote font=swiss j=r 'GR10N101 ';
 Note about code
pattern value=mempty color=blue repeat=49;
 Note about code
proc gmap data=lower48 map=lower48;
   id state;
   choro state / annotate=citystar discrete nolegend;

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.