Sample 24901: Outline selected counties within a region with PROC GMAP
This sample program uses PROC GMAP with the Annotate facility to outline selected counties within a region.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample program uses PROC GMAP with the Annotate facility to outline selected counties within a region.
The graphics output in the Results tab was produced using SASĀ® 9.2. Submitting
the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Create the data set, SWEST. Subset states in */
/* western region and assign counties to regions. */
data swest;
set maps.county;
if state in(4,8,35,49);
if state=4 then do; /* Arizona */
if county in(1,5,15,17)
then region='Flagstaff';
else region='Phoenix';
end;
if state=8 then do; /* Colorado */
if county in(33,67,83,85,91,111,113)
then region='Flagstaff';
else region='Denver';
end;
if state=35 then do; /* New Mexico */
if county in(17,23,29)
then region='Phoenix';
else if county in(31,45)
then region='Flagstaff';
else region='Santa Fe';
end;
if state=49 then do; /* Utah */
if county in(9,47)
then region='Denver';
else if county in(25,37,53)
then region='Flagstaff';
else region='Provo';
end;
run;
/* Project the map of western states. */
proc gproject data=swest out=swest;
id state county;
run;
/* Create a data set with only state borders. */
proc gremove data=swest out=stborder;
by state;
id county;
run;
/* Sort by region and create a data set with only */
/* region borders. */
proc sort data=swest out=swest2;
by region;
run;
proc gremove data=swest2 out=regbordr;
by region;
id county;
run;
/* Create an Annotate data set, ANNOST to draw */
/* state borders. */
data annost;
set stborder;
by state segment;
retain
size 4 /* line thickness */
color 'yellow' /* yellow border */
xsys '2' /* Use the map coordinate system.*/
ysys '2'
when 'a' ; /* Annotate after the map is drawn.*/
/* For the first point in each polygon or the */
/* first point of the interior polygon, set */
/* FUNCTION to 'POLY'. */
if first.segment or (lag(x)=. and lag(y)=.)
then function='POLY ';
/* For other points, set FUNCTION to 'POLYCONT'. */
else function='POLYCONT';
/* Don't output points with missing values. */
if x and y then output;
run;
/* Create an Annotate data set, ANNOREG, to draw the */
/* borders for the regions. */
data annoreg;
set regbordr;
by region segment;
retain
size 4 /* line thickness */
color 'black' /* black border */
xsys '2' /* Use the map coordinate system. */
ysys '2'
when 'a'; /* Annotate after the map is drawn. */
/* For first point in each polygon or first */
/* point of interior polygon, set FUNCTION */
/* to 'POLY'. */
if first.segment or (lag(x)=. and lag(y)=.)
then function='POLY ';
/* For other points, set FUNCTION to 'POLYCONT'. */
else function='POLYCONT';
/* Don't output points with missing values. */
if x and y then output;
run;
/* Combine the two Annotate data sets. */
data annoboth;
set annost annoreg;
run;
/* Add the title */
title1 'Western Conservation Regions';
/* Create the map, using the Annotate facility to */
/* draw state and region outlines. */
proc gmap map=swest data=swest anno=annoboth;
id state county;
choro region / coutline=white legend=legend1;
legend1 shape=bar(4,3) pct across=5 frame
cshadow=black label=none;
run;
quit;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample program uses PROC GMAP with the Annotate facility to outline selected counties within a region.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation
|
Date Modified: | 2005-08-31 03:03:07 |
Date Created: | 2004-11-11 11:07:57 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |