Chapter Contents |
Previous |
Next |
The GMAP Procedure |
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) |
The USCITY and USCENTER map data sets contain coordinates for labeling (see Specialty Map Data Sets
Contact Technical Support for a program that can be used to create the data sets from MAPS.WORLD.
The Version 6 data sets that contained multiple countries
have been divided into individual data sets, beginning in Version 7.
Locating Map Data Sets |
Accessing Descriptions of Map Data Sets |
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.
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.
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 |
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.
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.
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 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.
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.
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
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.
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;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.