GMAP Procedure

Example 3: Using GfK GeoMarketing Map Data to Specify Response Levels in a Block Map

Features:

MAP= required argument referring to GfK map data

DATA= argument referring to response data

ID statement

BLOCK statement options:
LEVELS=
SHAPE=
RELZERO
CEMPTY=
Other features:

System option FMTSEARCH=

SQL procedure

Data sets: MAPSGFK.SAMERICA (map data)

DEMOGRAPHICS (table of response data)

Format: ison2a
Sample library member: GMPGLEVL
CAUTION:
The GfK GeoMarketing map data set used in this example is licensed to be used only with SAS/GRAPH.
This example uses the LEVELS= option to specify the number of response levels for the blocks. The LEVELS= option tells GMAP how many response levels and the GMAP procedure calculates the quantiles.
Response Levels in Block 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 "Gross National Income per Capita";
title2 "South America";
footnote1 j=r "This map drawn with GfK map data";
proc gmap data=demographics(where=(cont=92))
map=mapsgfk.samerica all;
id iso;
block gni / levels=3 shape=prism
            relzero cempty=gray;
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 titles and footnote for the map.
title1 "Gross National Income per Capita";
title2 "South America";
footnote1 j=r "This map drawn with GfK map data";
Produce the block 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 LEVELS= option specifies the number of response levels for the graph. The SHAPE= option draws the blocks as prisms. The RELZERO option specifies that the block values are relative to zero. The CEMPTY= option specifies the outline color for map areas that have missing data. Note that the block map does not include the Caribbean islands. GfK offers the map data for those islands in a separate data set.
proc gmap data=demographics(where=(cont=92))
map=mapsgfk.samerica all;
id iso;
block gni / levels=3 shape=prism
            relzero cempty=gray;
run;
quit;