Chapter Contents

Previous

Next
The GMAP Procedure

SAS/GRAPH Map Data Sets

Many map data sets are provided with SAS/GRAPH software. Some of the more commonly used map data sets are listed in the following table (see the MAPS.METAMAPS data set for details on all the Institute-supplied map data sets). The items listed under each of the variable names describes the value type. For example, proj means that the value for the specified variable is a projected value and long or lat means that the value is unprojected longitude or latitude. If a variable does not exist in the map data set, n/a is used in the table.

Note:    The last two items in the table (Continents and International) are categories of map data sets. The map data sets in these categories contain individual countries, continents, or subdivisions. To see the complete list of map data sets that are provided in each of these categories, see the MAPS.METAMAPS data set.  [cautionend]

SAS/GRAPH Map Data Sets
Version 6 Variables Current Variables Compatible with V6?
Map Data Sets X Y LONG LAT X Y LONG LAT
US
proj proj n/a n/a proj proj n/a n/a yes
USCITY (table note 1) proj proj long lat proj proj long lat yes (table note 2)
USCENTER
proj proj long lat proj proj long lat yes
STATES
long lat n/a n/a long lat n/a n/a yes
COUNTIES
long lat n/a n/a long lat n/a n/a yes
COUNTY
long lat n/a n/a long lat n/a n/a yes
USCOUNTY
proj proj n/a n/a proj proj n/a n/a yes
CANADA
proj proj n/a n/a proj proj n/a n/a yes
CANADA2
proj proj n/a n/a proj proj n/a n/a yes
CANADA3
long lat n/a n/a long lat n/a n/a yes
CANADA4
long
n/a n/a long lat n/a n/a yes
WORLDPRJ
proj proj n/a n/a not available in current version not available in current version not available in current version not available in current version no
WORLDMAP
long lat n/a n/a not available in current version not available in current version not available in current version not available in current version no
WORLD
not available in Version 6 not available in Version 6 not available in Version 6 not available in Version 6 proj proj long lat no
Continents
proj proj n/a n/a proj proj long lat yes
International
proj proj n/a n/a proj proj long lat yes (table note 3)

TABLE NOTE 1:  

The USCITY and USCENTER map data sets contain coordinates for labeling (see Specialty Map Data Sets

for details) [arrow]

TABLE NOTE 2:  

Contact Technical Support for a program that can be used to create the data sets from MAPS.WORLD. [arrow]

TABLE NOTE 3:  

The Version 6 data sets that contained multiple countries have been divided into individual data sets, beginning in Version 7. [arrow]


Locating Map Data Sets

A collection of map data sets is supplied with SAS/GRAPH. Contact your SAS Support Consultant to verify the name and location of the SAS data library that contains the map data sets at your site before you use the map data sets. Many sites automatically assign a libref of MAPS to the SAS data library that contains the Institute-supplied map data sets. However, if you use the map data sets regularly and your site does not automatically assign a libref to the data library that contains the map data sets, you can add a LIBNAME statement to your AUTOEXEC file that defines the location of the map data set library. If you do this, the libref for the maps is established automatically whenever you begin a SAS session.


Accessing Descriptions of Map Data Sets

You may need detailed information on the map data sets in order to determine their size, the variables they contain, or whether they are projected or unprojected. You can get this information by using the CONTENTS or DATASETS procedure, or browsing the METAMAPS data set in the MAPS library (or the library where your Institute-supplied map data sets reside). For example, these statements list the map data sets in the SAS data library that is assigned to the libref MAPS:

libname maps 'SAS-data-library';

proc datasets lib=maps;
run;

Note:   Be sure to replace SAS-data-library with the location of the SAS data library that contains map data sets at your site.  [cautionend]

The following statements provide detailed information on the map data sets, including the number of observations, the variables in each data set, and a description of each variable:

libname maps 'SAS-data-library';

proc contents data=maps.canada3;
run;

To see the contents and descriptions of all of the Institute-supplied map data sets you can specify DATA=MAPS._ALL_ in the CONTENTS procedure. See the SAS Procedures Guide for more information on the CONTENTS and DATASETS procedures.


Using FIPS Codes and Province Codes

The map area identification variable in some map data sets that are included with SAS/GRAPH contain standardized numeric codes. The data sets for the United States contain a variable whose values are FIPS (Federal Information Processing System) codes. The data sets for Canada contain standard province codes or census division codes. When you use the GMAP procedure, the variables that identify map areas in your response data set must have the same values as the map area identification variables in the map data set that you are using. If the map area identification variables in your response data set are state or province names or abbreviations, convert them to FIPS codes or province codes before using the response data set with one of the Institute-supplied map data sets. U.S. FIPS Codes lists the FIPS codes for the United States and Canadian Province Codes lists the standard codes for Canadian provinces.

U.S. FIPS Codes
FIPS Code State FIPS Code State
01 Alabama 30 Montana
02 Alaska 31 Nebraska
04 Arizona 32 Nevada
05 Arkansas 33 New Hampshire
06 California 34 New Jersey
08 Colorado 35 New Mexico
09 Connecticut 36 New York
10 Delaware 37 North Carolina
11 District of Columbia 38 North Dakota
12 Florida 39 Ohio
13 Georgia 40 Oklahoma
15 Hawaii 41 Oregon
16 Idaho 42 Pennsylvania
17 Illinois 44 Rhode Island
18 Indiana 45 South Carolina
19 Iowa 46 South Dakota
20 Kansas 47 Tennessee
21 Kentucky 48 Texas
22 Louisiana 49 Utah
23 Maine 50 Vermont
24 Maryland 51 Virginia
25 Massachusetts 53 Washington
26 Michigan 54 West Virginia
27 Minnesota 55 Wisconsin
28 Mississippi 56 Wyoming
29 Missouri 72 Puerto Rico

Canadian Province Codes
Province Code Province
10 Newfoundland
11 Prince Edward Island
12 Nova Scotia
13 New Brunswick
24 Quebec
35 Ontario
46 Manitoba
47 Saskatchewan
48 Alberta
59 British Columbia
60 Yukon
61 Northwest Territories

Note:   The ID variables in Canadian maps are character.  [cautionend]

The CNTYNAME data set contains a cross-reference of names and FIPS codes for all counties in the United States. The CANCENS data set contains a cross-reference of census district names and codes for Canadian provinces.

Base SAS software provides several functions that convert state names to FIPS codes and vice versa. The following table lists these functions and a brief description of each. See SAS Language Reference: Dictionary for more information.

FIPS and Postal Code Functions
Function Description
STFIPS converts state postal code to FIPS state code
STNAME converts state postal code to state name in upper case
STNAMEL converts state postal code to state name in mixed case
FIPNAME converts FIPS code to state name in upper case
FIPNAMEL converts FIPS code to state name in mixed case
FIPSTATE converts FIPS code to state postal code


Using SAS/GRAPH Map Data Sets

You can customize the area that is displayed on your map by using only part of a particular map data set. There are several ways to accomplish this. You can use WHERE processing or a DATA step to subset the map data to be used by the GMAP procedure. You can also use the GPROJECT procedure to create a rectangular subset of a map data set by using minimum and maximum longitude and latitude values.

You can combine map data sets in either of these situations:

Institute-supplied map data sets that have coordinates expressed only as longitude and latitude, with variable names LONG and LAT, must be renamed X and Y and should be projected before displaying.

Subsetting Map Data Sets

Some of the map data sets that are included with SAS/GRAPH contain a large number of observations. Programs that use only a few states or provinces will run faster if you exclude the unused portion of the map data set or use an already reduced map data set. The SAS System provides several ways to accomplish this. One is to use the WHERE statement or WHERE= data set option within the GMAP procedure to select only the states or provinces you want.

For example, to use only the observations for Quebec in the CANADA data set, begin the GMAP procedure with this statement:

proc gmap map=maps.canada(where=(province='24'));

If you use the WHERE statement, the WHERE condition applies to both the map data set and the response data sets. The WHERE= data set option applies only to the data set that you specify in the argument in which the WHERE= option appears.

The WHERE statement and WHERE= data set option are most useful when you produce a simple map and do not need to make any other changes to the data set.

Another approach is to use a DATA step to create a subset of the larger data set. This code illustrates another way to extract the observations for Quebec from the CANADA data set:

data quebec;
   set maps.canada(where=(province='24'));

This approach is most useful when you want to create a permanent subset of a map data set or when you need to make additional changes to the map data set.

Also see The GREMOVE Procedure for an example how to use GREMOVE to create a regional map from one of the data sets that are supplied with SAS/GRAPH.

Reducing Map Data Sets

You can reduce map data sets. A reduced map data set is one that can be used to draw a map that retains the overall appearance of the original map but that contains fewer points, requires considerably less storage space, and can be drawn much more quickly. You can improve performance by plotting fewer observations for each map area. You reduce a map data set when you subset it on the variable DENSITY. You can add the variable DENSITY to a map data set by using the GREDUCE procedure. For more information, see The GREDUCE Procedure.

An unreduced map data set contains all of the coordinates that were produced when the map was digitized. This type of map data set has more observations than most graphics output devices can accurately plot. Some unreduced map data sets already contain a DENSITY variable like the one calculated by the GREDUCE procedure, so it is not necessary to use the GREDUCE procedure to process these data sets. Values for DENSITY range from 0 through 6 (the lower the density, the coarser the boundary line).

A statement of this form excludes all points with a density level of 2 or greater:

proc gmap map=maps.states(where=(density<2));

The resulting map is much coarser than one drawn by using all of the observations in the data set, but it is drawn much faster.

Another way to create a reduced map data set is to use a DATA step to exclude observations with larger density values:

data states;
   set maps.states(where=(density<2));

Projecting Map Data Sets

Map data can be stored as unprojected or projected coordinates. Unprojected map data contains spherical coordinates, that is, longitude and latitude values usually expressed in radians. (footnote 1) A few map data sets that are provided with SAS/GRAPH contain only unprojected coordinates and should be projected before you use them. They are
CANADA3
CANADA4
COUNTIES
COUNTY
STATES

Projected map data contains Cartesian coordinates. The GMAP procedure is designed to plot maps by using projected map data sets. Most SAS/GRAPH map data sets contain projected coordinates that are stored as X and Y. If the projection supplied with the map data set does not meet your needs, you can use the GPROJECT procedure to create a different projection. You should select a projection method that least distorts the regions that you are mapping. (All projection methods inherently distort map regions.) See The GPROJECT Procedure for more information.

Note:   Using an unprojected map data set with the GMAP procedure can cause your map to be reversed and distorted.  [cautionend]

Controlling the Display of Lakes

Some countries contain a lake that is located completely within a single unit area. Occasionally these lakes can be a problem. For example, displaying lakes in prism maps may cause undesirable results. In addition, displaying lakes may not be appropriate for some applications. In these cases, you may want to remove the lakes from the map data set before you proceed.

Map data sets that contain coordinates for a lake that is located within a single internal division are identified by the presence of the character variable LAKE. The value of LAKE is 1 for points that correspond to lakes and 0 otherwise. The following statements illustrate how to delete the lakes from your map data sets using WHERE processing:

proc gmap map=maps.chile(where=(lake='0'))
          data=maps.chile;
   id id;
   choro id / levels=1 nolegend;
   title box=1 f=none h=4
         'Chile with Lakes Removed';
run;

You can also create a new map data set that is a subset of the map data set:

data nolake;
   set maps.chile;
   if lake='0';
run;

FOOTNOTE 1:  If your data is in degrees, it can be converted to radians by multiplying by the degree-to-radian constant [atan(1)/45]. [arrow]


Chapter Contents

Previous

Next

Top of Page

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