ccmap Produce a conditioned choropleth map ccmap

SAS Macro Programs: ccmap

$Version:
Michael Friendly
York University


The ccmap macro ( [download] get ccmap.sas)

Produce a conditioned choropleth map

The CCMAP macro produces a set of choropleth maps for one response variable where the geographic units are partitioned into groups by two conditioning variables. Each region appears in all maps, but is only shaded (in relation the the RESPONSE= variable) in those views defined by the ranges of the conditioning (GIVEN=) variable. This makes it possible to see how the geographic distribution of the response changes with the conditioning variables.

See: Dan Carr's CCmaps page: http://www.galaxy.gmu.edu/~dcarr/CCmaps/ for information on CCmaps.

Usage

The CCMAP macro is defined with keyword parameters. The RESPONSE= (or VAR=) variable is required, as are two GIVEN= variables. The ID= variable must name the geographic region in the MAP= and DATA= data sets. The arguments may be listed within parentheses in any order, separated by commas. For example:

  %ccmap();

For useful results, you should also specify the MIDPOINTS= values of the RESPONSE= variable and define a corresponding set of PATTERN statements.

Parameters

DATA=
The name of the input data set
MAP=
Name of the input map data set [Default: MAP=MYMAPS.USVISMAP]
RESPONSE=
Response variable shown on maps
VAR=
Synonym for RESPONSE=
ID=
The name of the map ID variable indicating geographic regions in the MAP= and DATA= data sets.
WEIGHT=
Region weight variable (e.g. population), used for calculating weighted means/medians for the levels of the conditioning variables.
GIVEN=
The names of 2 Conditioning variables, X, Y
SLICES=
Number of slices for X,Y [Default: SLICES=2 2]
OVERLAP=
Allowed overlap between slices of the GIVEN= variables, in percent. Ignored if the given variables are character. [Default: OVERLAP=0.10]
LEVELS=
Number of levels for the VAR= variable in the maps [Default: LEVELS=7]
MIDPOINTS=
Midpoints for the VAR= variable. You should use this to specify a common set of midpoints for the response variable in the maps, so they all use the same midpoints. You can append PCT to a list of numeric midpoint values to have the macro calculate the corresponding percentiles of the VAR= variable. Specifying MIDPOINTS= overrides the LEVELS= parameter.
COUTLINE=
Outline color for the map regions. Specify COUTLINE=, (null) to suppress the region outlines. [Default: COUTLINE=GRAYCC]
LEGEND=
NONE, or name of a LEGEND statement, e.g., LEGEND=LEGEND1. If you do not specify LEGEND=, you will get a default PROC GMAP legend in each map, probably not what you want.
GMAPOPTIONS=
Other GMAP options
ANNO=
Name of an additional input annotate dataset. If supplied, this is used in all of the maps.
HSTRIP=
Height (in %) for marginal label strip used to identify the values of the GIVEN= variables. [Default: HSTRIP=6]
STRIPBG=
Strip background color [Default: STRIPBG=YELLOW]
STRIPFG=
Strip foreground color [Default: STRIPFG=BLACK]
GTEMP=
Temporary graphics catalog used to generate the individual maps. [Default: GTEMP=GTEMP]
KILL=
Delete gtemp when done? [Default: KILL=Y]
GOUT=
The name of the graphics catalog [Default: GOUT=GSEG]
NAME=
The name of the graph in the graphic catalog [Default: NAME=CCMAP]

Dependencies

CCMAP requires the following macros:

  gdispla.sas     Device-independent DISPLAY/NODISPLAY control
  panels.sas      Display a set of plots in rectangular panels
  slice.sas       Divide a variable into slices

Example

 %include macros(ccmap);        *-- or include in an autocall library;
 %include data(guerry);

 *-- Define a palette of 7 colors from Red to Blue thru Yellow;
 %brewerpal(n=7, palette=RdYlBu, out=palette);
 %genpat(data=palette, n=nobs, colors=color);

 legend1
    mode=share
    position=(bottom inside left)
    across=4
    label=(position=middle j=c 'Pop/Crime' j=c '(00s)')
    shape=bar(3,1);

 %ccmap(data=guerry, map=mymaps.gfrance(where=(density<5)),
    var=Crime_pers, given=Literacy Wealth,
    id=dept, weight=Pop1831,
    midpoints = 20 30 40 50 60 70 80 PCT,
    legend=legend1,
    slices=2 2, overlap=0.10);

See also

brewerpal Generate Brewer color palette(s)
colorramp Construct a sequential or diverging color set
gdispla Device-independent DISPLAY/NODISPLAY control
slice Divide a variable into slices, allowing overlap
gensym Generate PATTERN statements
panels Macro to display a set of plots in rectangular panels