GMAP Procedure

Example 9: Using GfK GeoMarketing Map Data to Produce a Simple Choropleth Map

Features:

MAP= required argument referring to GfK map data

DATA= argument referring to response data

ID statement

CHORO statement options:
STAT=
CDEFAULT=
Other features:

System option FMTSEARCH=

SQL procedure

Data sets: MAPSGFK.EUROPE (map data)

DEMOGRAPHICS (table of response data)

Format: ison2a
Sample library member: GMPGCHOR
CAUTION:
The GfK GeoMarketing map data set used in this example is licensed to be used only with SAS/GRAPH.
This example produces a choropleth (two-dimensional) map that shows the population of countries in Europe. Since the DISCRETE option is not used, the response variable is assumed to have a continuous range of values. Because neither the LEVELS= nor MIDPOINTS= options are used, the GMAP procedure selects a number of levels based on the number of map areas. It then calculates the appropriate response levels. The legend shows the range of values for each level.
A Simple Choropleth Map With GfK Map Data

Program

options fmtsearch=(sashelp.mapfmts);
proc sql;
create table demographics(rename=(iso=oiso newiso=iso id=oldid newid=ID)) as
select demo.*, 
put(demo.iso,z3.) as newiso format=$3.,
put(demo.iso,ison2a.) as newid 
from sashelp.demographics as demo
;
alter table demographics
modify ID char(15) label='Alpha2 Country Code';
quit;
goptions reset=all border;
title1 "Population in Europe";
footnote j=r "This map drawn with GfK map data";
proc gmap map=mapsgfk.europe(where=(id not in:('SJ' 'TR')))
                data=demographics(where=(cont=93)) all;
id id;
choro pop / cdefault=yellow stat=first;
run;
quit;

Program Description

Specify the format catalog to search that has the predefined ISO alpha2 code.
options fmtsearch=(sashelp.mapfmts);
Create a table named demographics using sashelp.demographics as the base and changing its variables to match GfK variable types and lengths. This table will be used as the response data set. Note that the ISO variable was numeric in the original sashelp.demographics data but is the character variable OISO in the GfK map data set. The format 'ison2a' uses the country's ISO numeric code to output the country's ISO alpha2 code. Also note that the ID variable was a numeric geographic locator code (glc) in the original sashelp.demographics data but is represented by the ISOALPHA2 variable in the GfK map data set.
proc sql;
create table demographics(rename=(iso=oiso newiso=iso id=oldid newid=ID)) as
select demo.*, 
put(demo.iso,z3.) as newiso format=$3.,
put(demo.iso,ison2a.) as newid 
from sashelp.demographics as demo
;
alter table demographics
modify ID char(15) label='Alpha2 Country Code';
quit;
Set the graphics environment.
goptions reset=all border;
Define the title and the footnote for the map.
title1 "Population in Europe";
footnote j=r "This map drawn with GfK map data";
Produce the choropleth map. The ALL argument specifies that the output should include all of the map areas from the map data set, even if the response data set DEMOGRAPHICS does not include an observation for the map area. The output shows 3 such areas. The ID statement specifies the variable that is in both the map data set and the response data set that defines map areas. CDEFAULT= specifies the color for the map areas that have missing data. In this map Montenegro, Kosovo, and the island of Cyprus are yellow, indicating missing data. The STATISTIC= option specifies that the GMAP procedure will match the first observation from MAPSGFK.EUROPE data set and output the response value from this observation only. The WHERE= clause on the MAP= option excludes the islands of Cyprus and Svalbard, the country Turkey, and the Russian region. All of these map areas have no data in the DEMOGRAPHICS data set.
proc gmap map=mapsgfk.europe(where=(id not in:('SJ' 'TR')))
                data=demographics(where=(cont=93)) all;
id id;
choro pop / cdefault=yellow stat=first;
run;
quit;