GMAP Procedure

Example 21: Mapping an Individual Country By Subsetting MAPS.WORLD

Features:

OPTIONS statement

MAPS= required argument referring to traditional map data

DATA= required argument referring to response data

FORMAT statement

ID statement

CHORO statement option STAT=

Other features:

SQL procedure

Data sets: MAPS.WORLD (map data)

MYDATA (table with subsetted map data)

Format: GLCNSM
Sample library member: GMPCOUNT
Note: This example cannot be run with a GfK map data set. The glc codes are replaced by ISO codes and are not supported for GfK mapping.
This example shows how to subset a single country from the MAPS.WORLD data set. This is useful for mapping smaller countries that do not have an individual map data set in the MAPS or MAPSSAS library.
This example also demonstrates how to use the GLCNSM. format to specify a country by name rather than by its ID value.
Mapping an Individual Country by Subsetting MAPS.WORLD

Program

goptions reset=all border;
options fmtsearch=(sashelp.mapfmts);
proc sql;
 create table mymap as
 select * from maps.world
 where put(id,glcnsm.) eq "Bahamas"
 ;
 run;
proc gmap map=mymap data=mymap;
 format id glcnsm.;
 id id;
 choro id / stat=first;
run;
quit;

Program Description

Set the graphics environment.
goptions reset=all border;
Enable the formats from the SASHELP.MAPFMTS catalog.
options fmtsearch=(sashelp.mapfmts);
Subset the map data for the Bahamas from MAPS.WORLD by using the SQL procedure and the geographic locator code format (glcnsm).
proc sql;
 create table mymap as
 select * from maps.world
 where put(id,glcnsm.) eq "Bahamas"
 ;
 run;
Create the map by using the GMAP procedure.The STATISTIC= option specifies that the GMAP procedure will match the first observation from the MYMAP data set and output the response value from this observation only.
proc gmap map=mymap data=mymap;
 format id glcnsm.;
 id id;
 choro id / stat=first;
run;
quit;