GMAP Procedure

Example 13: Using GfK GeoMarketing Map Data to Produce a Simple Prism Map

Features:

MAP= required argument referring to GfK map data

DATA= argument referring to response data

ID statement

PRISM statement options:
CDEFAULT=
RELZERO
Other features:

System option FMTSEARCH=

SQL procedure

Data sets: MAPSGFK.AFRICA (map data)

DEMOGRAPHICS (table of response data)

Format: ison2a
Sample library member: GMPGPRSM
CAUTION:
The GfK GeoMarketing map data set used in this example is licensed to be used only with SAS/GRAPH.
Producing a Simple Prism 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 Africa";
footnote1 j=r "This map drawn with GfK map data"; 
proc gmap data=demographics(where=(cont=94))
          map=mapsgfk.africa(where=(lake=0)) density=low all;
   id id;
   prism pop / cdefault=yellow relzero;
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 footnote for the map
title1 "Population in Africa";
footnote1 j=r "This map drawn with GfK map data"; 
Produce the prism map.The WHERE= clause in the DATA= statement includes the countries that are part of the continent of Africa. The WHERE= clause in the MAP= statement excludes lake areas. 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 1 such area. The ID statement specifies the variable in the map data set and the response data set that defines map areas. The CDEFAULT= option sets the color of map areas that have missing data. The RELZERO option makes the prism heights relative to zero.
proc gmap data=demographics(where=(cont=94))
          map=mapsgfk.africa(where=(lake=0)) density=low all;
   id id;
   prism pop / cdefault=yellow relzero;
run;
quit;