Producing Maps with SAS/GRAPH
The
GMAP procedure in the SAS/GRAPH module of
SAS for Windows is a powerful tool for visually summarizing
spatial relationships in data. A wealth of governmental statistics, census
data, and other survey data is reported at various levels of geographical
disaggregation suitable for mapping.
U.S. census data, for example, includes information on population
characteristics ranging from religious affiliation to ethnicity to educational
background to economic status at the national, state and county levels. Data on
the economy and voting behavior are often available for these political units
as well. GMAP can produce block, cloropleth, prism and surface
maps from such data. For examples of these map types and for more information
than can be provided here, see the GMAP chapter of the
SAS/Graph User's Guide.
SAS/GRAPH produces maps using special SAS datasets which contain administrative identification numbers for each map region and coordinates which define that region's boundaries. For most of the map datasets included with the SAS/GRAPH system, there is an accompanying, nonmap dataset which matches these identification numbers with the names of the corresponding geographical units; it is not usually necessary to look up these codes. For example, the BRAZIL dataset contains administrative identifiers and boundary coordinates for all of the Brazilian states. The BRAZIL2 dataset pairs the SAS-assigned state codes with the names of the states. All that is necessary is that the data to be mapped is organized according to these same administrative units or groups of these units.
Current versions of SAS for Windows include maps for the
world's major nations and continents. On the Statlab Novell network the map
datasets have been installed in the directory
H:\SASMAPS\MAPS . In addition to the maps which come with
SAS, a large number of additional map datasets--including block maps of New
Haven--can be purchased from the SAS Institute.
Before you can produce your map in GMAP,
you specify a device to which to send the map using the GOPTIONS
statement.
If you use SAS at the Statlab the autoexec.sas issues
the necessary GOPTIONS statement.
You can browse the complete list of device options using the following command in the SAS command box:
AF C=SASHELP.GRAPH.GDSCAN.PROGRAM.
To display a graph on the screen
GOPTIONS device=win;
For plotter output
GOPTIONS device=winplot;
For laser printer output (default on Statlab's SAS for Windows)
GOPTIONS device=winprt cback=white;If you use SAS For Windows, this options displays the graph on the screen.
You can print the graph by clicking the
Print button.
To save to a file
FILENAME <file ref> '<path/filename>'; GOPTIONS device=<output device id> gaccess=<file ref>
Example SAS program
The following example SAS program produces a cloropleth map of corn production in U.S. states and in so doing utilizes most of the basic commands relevant to mapping in SAS. This program could be taken as a model and easily altered to produce a map of, say, mixed language marriages per capita in Swiss cantons.
goptions device = win;
DATA ag;
INPUT state corn @@;
CARDS;
01 14580 02 . 04 4000 05 1036 06 36450 08 89680 09 . 10 12744 12 15416
13 54600 15 . 16 4700 17 1065780 18 602880 19 1463000 20 116560 21 103600
22 1380 23 . 24 46080 25 . 26 247000 27 610130 28 2464 29 109710 30 592
31 603500 32 . 33 . 34 7725 35 7225 36 67890 37 103800 38 16820 39 440700
40 5250 41 1166 42 9600 44 . 45 24720 46 121900 47 28600 48 11700 49 1500
50 . 51 32725 53 11280 54 5162 55 348400 56 3589
;
PROC FORMAT;
value stfmt (default = 20)
. = 'None'
1 - 10000 = '1-10,000'
10001 - 50000 = '10,001-50,000'
50001 - 100000 = '50,001-100,000'
100001 - 500000 = '100,001-500,000'
500001 - 1000000 = '500,001-1,000,000'
1000001 - high = '1,000,001 and up';
pattern1 v = e c = black;
pattern2 v = m1x45 c = black;
pattern3 v = m2x45 c = black;
pattern4 v = m3x45 c = black;
pattern5 v = m4x45 c = black;
pattern6 v = m5x45 c = black;
pattern7 v = s c = black;
title1 c = black 'Corn Production';
title2 c = black 'Thousands of Bushels';
footnote1 ' ';
footnote2 c = black j = c
'Source: World Almanac and Book of
Facts, 1982';
legend1 label = none across = 2;
/* The libname points to the directory where
the SAS maps are stored */
LIBNAME maps 'H:\sasmap\maps';
data usmap;
set maps.us;
proc gmap data = ag
map = usmap
all;
id state;
format corn stfmt.;
choro corn / discrete
missing
legend = legend1
ctext = black
coutline = black;
run;
lm: December 20, 2001
