GMAP Procedure

Example 5: Using GfK GeoMarketing Map Data to Assign a Format to the Response Variable

Features:

MAP= required argumentreferring to GfK map data

DATA= argument referring to response data

FORMAT statement

ID statement

AREA statement option MIDPOINTS=

BLOCK statement options:
LEGEND=
RELZERO
LEVELS=
Other features:

System option FMTSEARCH=

SQL procedure

FORMAT procedure

LEGEND statement

Data sets: MAPSGFK.ASIA (map data)

DEMOGRAPHICS (table of response data)

Format: ison2a
Sample library member: GMPGFRMT
CAUTION:
The GfK GeoMarketing map data set used in this example is licensed to be used only with SAS/GRAPH.
This example creates formats for the response variables. The format for the POP variable defines and labels ranges of values. These ranges appear in the legend and make the map easier to understand. The example also uses the AREA statement to patterns the map areas by region. The elongated countries in the output indicate that GfK uses a different projection method than does output created with a traditional Asia map data set.
Assigning Format to the Response Variables 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;
proc format;
  value popfmt low-1000000="0-1"
               1000001-10000000="1-10"
               10000001-100000000="10-100"
               100000001-500000000="100-500"
               500000001-high="over 500";
run;
proc format;
  value $ regionfmt "SEAR" = "South-East Asia"
                    "EUR" = "Europe"
                    "EMR" = "Eastern Mediterranean"
                    "WPR" = "Western Pacific";
run;
title1 "Population Data for Asia (2005)";
footnote j=r "This map drawn with GfK map data";
legend1 label=("Population (Millions)");
proc gmap data=demographics(where=(cont=95))
map=mapsgfk.asia all;
format pop popfmt.;
format region $regionfmt.;
id id;
area region / midpoints="SEAR" "EUR" "EMR" "WPR";
block pop / legend=legend1
            relzero
            levels=all;
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;
Create a format for the POP variable.POPFMT. defines the ranges of values for POP and labels the values.
proc format;
  value popfmt low-1000000="0-1"
               1000001-10000000="1-10"
               10000001-100000000="10-100"
               100000001-500000000="100-500"
               500000001-high="over 500";
run;
Create a format for the REGION variable.REGIONFMT. labels the values for REGION.
proc format;
  value $ regionfmt "SEAR" = "South-East Asia"
                    "EUR" = "Europe"
                    "EMR" = "Eastern Mediterranean"
                    "WPR" = "Western Pacific";
run;
Define the title and footnote for the map.
title1 "Population Data for Asia (2005)";
footnote j=r "This map drawn with GfK map data";
Assign the legend label.
legend1 label=("Population (Millions)");
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 output shows 1 such area. The FORMAT statements assign POPFMT. to the POP variable and $REGIONFMT. to the REGION variable. The ID statement assigns the variable ID — which represents the ISOALPHA2 variable after the variable rename when the demographics table was set up. The AREA statement assigns patterns to the map areas according to the values of the REGION variable. The RELZERO option specifies that the blocks values are relative to zero. The LEVELS= option is used to graph all unique ID response variable values.
proc gmap data=demographics(where=(cont=95))
map=mapsgfk.asia all;
format pop popfmt.;
format region $regionfmt.;
id id;
area region / midpoints="SEAR" "EUR" "EMR" "WPR";
block pop / legend=legend1
            relzero
            levels=all;
run;
quit;