Sample 24904: Thicken the map outline
/*******************************************************************/
/* This sample program produces a map of Arizona, Colorado, */
/* New Mexico, and Utah with thick state outline. */
/* You can change the width of the line by changing the value of */
/* the SIZE variable in the ANNO annotate data set. */
/* */
/* Since we're using an unprojected county map, we need to use the */
/* GPROJECT procedure to project the map data. Subset the */
/* specified states during the projection. */
/* If you include Alaska, you may want to use the gnomonic */
/* projection with the polelong option to better center the map. */
/*******************************************************************/
/* Create a projected map data set named MAP */
proc gproject data=maps.county out=map;
id state county;
/* Use the state FIPS codes to subset the desired states */
where state in (4 8 35 49);
run;
quit;
/* Since we want to thicken the outline of the state boundaries, */
/* we need to get the coordinates for the state outlines. Using */
/* the GREMOVE procedure, we can remove the county boundaries to */
/* create a data set of only the state boundaries. */
/* Create a data set named STATES that contains the state boundaries */
proc gremove data=map out=states;
/* STATE is the new identification variable */
by state;
/* STATE and COUNTY were the original identification variables */
id state county;
run;
quit;
/* Increment the SEGMENT variable value for all lake coordinates */
/* indicated by missing X and Y values. */
data states;
set states;
by state;
retain flag num 0;
/* Reset the flag value for each state */
if first.state then do;
flag=0;
num=0;
end;
/* Set the flag value when x and y are missing */
if x=. and y=. then do;
flag=1;
num + 1;
delete;
end;
/* Increment the segment value */
if flag=1 then segment + num;
drop flag num;
run;
/* Use the Annotate Facility to draw the outlines for the states */
/* */
/* The data coordinate system of '2' is used for XSYS and YSYS to */
/* place the annotation on the map at the correct location. The */
/* WHEN variable is set to 'A' to place the annotation after the */
/* procedure output has been drawn. The color for the outlines is */
/* set to black. The size of the outline is set to 5. The color */
/* and size of the outlines can be changed by changing the values */
/* in the COLOR and SIZE variables, respectively. */
/* Create an annotate data set named ANNO for the state outlines */
data anno;
length function color $8;
retain xsys ysys '2' when 'a' color 'black' size 5 xsave ysave;
drop xsave ysave;
set states;
by state segment;
/* Move to the first coordinate */
if first.segment then do;
function='move';
xsave=x;
ysave=y;
output;
end;
/* Draw to each successive coordinate */
else do;
function='draw';
output;
/* Connect the last coordinate to the first */
if last.segment then do;
x=xsave;
y=ysave;
output;
end;
end;
run;
title 'Thick State Outline on County Map';
/* Generate a county map with thick state boundaries */
proc gmap data=map map=map;
id state county;
choro county / anno=anno discrete nolegend;
run;
quit;

This sample program will produce a county map of Arizona, Colorado, New Mexico, and Utah with thick state outlines.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Maps ==> Map boundaries
|
| Date Modified: | 2005-08-31 03:03:08 |
| Date Created: | 2004-11-11 11:07:58 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |