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. ![[cautend]](../common/images/cautend.gif)
TABLE NOTE 1:
The USCITY
and USCENTER map data sets contain coordinates for labeling (see
for details)
TABLE NOTE 2:
Contact Technical Support
for a program that can be used to create the data sets from MAPS.WORLD.
TABLE NOTE 3:
The Version 6 data sets that contained multiple countries
have been divided into individual data sets for Version 7.
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.
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. ![[cautend]](../common/images/cautend.gif)
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.
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.
Note:
The ID variables in Canadian maps
are character. ![[cautend]](../common/images/cautend.gif)
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.
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.
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.
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));
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
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. ![[cautend]](../common/images/cautend.gif)
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].
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.