GMAP Procedure

Using GfK Map Data Sets with Existing Code

Reworking Code That Uses Traditional Map Data Sets

Overview

This section presents several examples of existing code that uses traditional map data sets, with tips for repurposing the code to use GfK map data and variables. The existing code fragment is shown first, followed by the code rewritten with the recommended changes. The tips and details of the change are presented as /* comments */ within each section of rewritten code.

Code to Prepare a Choropleth Map of Afghanistan

If you have existing code similar to the following:
proc gmap data=mydata map=maps.afghanis;
id id;
choro id / nolegend;
run;
Rewrite the code as follows to use a GfK map data set and ensure that the id-variable, in this case ID, is a matching character format between the response data set and the input data set:
/* Change the traditional map data set name (maps.afghanis) */
/* to the GfK map data set name (mapsgfk.afghanistan) */
/* The id-variable value in mydata must match the GfK id-variable character format */
/* GfK id-variables ID and ID1 are character format */
proc gmap data=mydata map=mapsgfk.afghanistan;
id id;
choro id / nolegend;
run;

Code to Prepare a Map of Europe for Annotation

If you have existing code similar to the following:
proc gmap data=mydata map=maps.europe;
id id;
choro id / levels=1 
           nolegend
           anno=mypoints;
run;
Rewrite the code as follows to use a GfK map data set and a different id-variable because ID is now character format:
/* Change the traditional map data set name (maps.europe) */
/* to the GfK map data set name (mapsgfk.europe) */
/* If the id-variable value in 'mydata' is numeric choose the GfK id-variable SEGMENT, which is also numeric format, or create your own variable */
/* Note that GfK id-variables ID and ID1 are character format */
/* The LEVELS=<number-of-midpoints> option will only work with numeric response variable values */
proc gmap data=mydata map=mapsgfk.europe;
id segment;
choro segment / levels=1 
           nolegend
           anno=mypoints;
run;

Code to Prepare a United States Map After Projecting Spherical Coordinates (Longitude and Latitude)

If you have existing code similar to the following, which projects the X and Y coordinate units in radians:
proc gproject data=maps.states out=mystates project=lambert;
id state;
run;

proc gmap data=mydata map=mystates;
id state;
choro state / nolegend;
run;
Rewrite the code as follows to use the GfK map data set and the projected X and Y coordinates (in degrees) provided in the input data set:
/* Change the traditional map data set name (maps.states) to the GfK map data set name mapsgfk.us_states */
/* Remove Proc GPROJECT and use the provided projected coordinates in degrees */
proc gmap data=mydata map=mapsgfk.us_states;
id state;
choro state / nolegend;
run;

Code to Project Annotate Data with a GfK Map Data Set

Use the following code to only project the annotate data and not the map data already projected:
/* mapsgfk.projparm is the data set that contains input projection parameters. */
/* us.states is the entry in the projection parameters data set that is used for input parameters, */
 /* mapsgfk.us_states is the GfK map data set for the United States */
/* containing unprojected longitude (X) and latitude (Y) variables in radians */

proc gproject data=anno out=annoproj parmin=mapsgfk.projparm parmentry=us.states;
run;

proc gmap data=mydata map=mapsgfk.us_states anno=annoproj;
id state;
choro state / nolegend;
run;