Discussion:
SAS Maps and Alaska Counties
(too old to reply)
Steve James
2007-07-25 14:17:39 UTC
Permalink
Dear SAS-L

I need to produce a map of the US by counties. Ideally it would be a map
where Alaska and Hawaii are shown just below the other 48 states. Using
maps.uscounty I get nearly everything I need except that in that dataset the
value for county in all the Alaska observations is 0. All the other map
datasets I saw have Alaska and Hawaii in their geographically correct place.
It seems odd to me that Alaska should be singled out. Am I missing something?

Steve James
Centers for Disease Control and Prevention
Chris Brooks
2007-07-25 14:32:22 UTC
Permalink
Steve

I'm no expert on Alaska but according to this
http://en.wikipedia.org/wiki/Counties#United_States the state is not
divided into counties...........

Chris

Chris Brooks
SAS Technical Lead
Office for National Statistics
United Kingdom
Post by Steve James
Dear SAS-L
I need to produce a map of the US by counties. Ideally it would be a map
where Alaska and Hawaii are shown just below the other 48 states. Using
maps.uscounty I get nearly everything I need except that in that dataset
the
Post by Steve James
value for county in all the Alaska observations is 0. All the other map
datasets I saw have Alaska and Hawaii in their geographically correct
place.
Post by Steve James
It seems odd to me that Alaska should be singled out. Am I missing
something?
Post by Steve James
Steve James
Centers for Disease Control and Prevention
Steve James
2007-07-25 15:03:52 UTC
Permalink
Thanks. I see that what Alaska has aren't called counties so perhaps I
shouldn't be surprised that they have a value of 0 in a map dataset. But
they do have FIPS "county" codes defined for AK and in maps.counties there
are non-zero values in the variable COUNTY. It would seem then that my only
recourse is to modify maps.counties so that AK and HI are positioned where I
want them, which will take some trial and error. Has anyone done this?

Steve
Chris Brooks
2007-07-25 15:49:26 UTC
Permalink
One possibility would be to try to obtain an ESRI shape file with the
boroughs delimited on it and use Proc Mapimport to create a SAS map data
set. I did this sort of thing a few years ago when I needed a map with UK
counties on it. The SAS supplied maps were years out of date but
fortunately we had a shape file with the correct boundaries on it which I
imported and then manipulated to get the subset of regions I wanted.

As far as positioning the States is concerned I'd first check out Mike
Zdeb's SUGI papers - as far as I'm concerned he's the guru on SAS mapping
and I'm sure he must have done something like this in one of his papers.

Chris

Chris Brooks
SAS Technical Lead
Office for National Statistics
United Kingdom

On Wed, 25 Jul 2007 08:36:09 -0700, Dennis G. Fisher, Ph.d.
Alaska has boroughs which fill the same function as counties. Anchorage
merged the Borough of Anchorage with
the Municipality of Anchorage and it is now called the Municipality of
Anchorage. All the rest of Alaska is
organized into Boroughs. If memory serves me correctly, I thought that
MapInfo had the maps of the Boroughs.
HTH
Dennis Fisher
Post by Steve James
Thanks. I see that what Alaska has aren't called counties so perhaps I
shouldn't be surprised that they have a value of 0 in a map dataset.
But
Post by Steve James
they do have FIPS "county" codes defined for AK and in maps.counties
there
Post by Steve James
are non-zero values in the variable COUNTY. It would seem then that my
only
Post by Steve James
recourse is to modify maps.counties so that AK and HI are positioned
where I
Post by Steve James
want them, which will take some trial and error. Has anyone done this?
Steve
Dennis G. Fisher, Ph.d.
2007-07-25 15:36:09 UTC
Permalink
Alaska has boroughs which fill the same function as counties. Anchorage
merged the Borough of Anchorage with
the Municipality of Anchorage and it is now called the Municipality of
Anchorage. All the rest of Alaska is
organized into Boroughs. If memory serves me correctly, I thought that
MapInfo had the maps of the Boroughs.

HTH
Dennis Fisher
Post by Steve James
Thanks. I see that what Alaska has aren't called counties so perhaps I
shouldn't be surprised that they have a value of 0 in a map dataset. But
they do have FIPS "county" codes defined for AK and in maps.counties there
are non-zero values in the variable COUNTY. It would seem then that my only
recourse is to modify maps.counties so that AK and HI are positioned where I
want them, which will take some trial and error. Has anyone done this?
Steve
Renee Jaramillo
2007-07-25 18:32:33 UTC
Permalink
I’ve run into this issue of needing to “move” Alaska and Hawaii to the
lower left corner of the graph. When I contacted SAS Tech Support, Sue
Morrison was kind enough to send me some sample code which I’ve included
below. Basically you separately project Alaska, Hawaii, and the contiguous
US, adjust the coordinates for Alaska and Hawaii to move to the lower left
corner, and then recombine all data before using GMAP. This example does
annotate and uses maps.states, but it would be easy to experiment and
substitute maps.counties.

Hope this helps,
Renee

= = = = = = = = = =
/* This program demonstrates how to apply annotation to */
/* a U.S. map which includes Alaska and Hawaii. AK and HI */
/* are moved beneath the continental U.S. */

/* Create a sample annotate data set of state capitals. */
data anno(drop=long lat capital);
length function style color $8;
retain xsys ysys '2' flag 1 when 'a';

/* Get city coordinates from the MAPS.USCITY data set. */
set maps.uscity(keep=state long lat city capital);

/* Label only the state capitals. */
where capital='Y';

/* Convert degrees to radians. */
x=(atan(1)/45)*long;
y=(atan(1)/45)*lat;

/* Create an observation to label the x,y coordinate */
/* with a red star. */
function='label';
style='special';
text='M';
color='red';
position='5';
size=1.5;
output;

run;

/* Separate the annotate data set into coordinates */
/* for Alaska, Hawaii, and the continental U.S. */

/* Annotate data sets will be projected with map */
/* data sets below. */
data annous annoak annohi;
set anno;

if state=2 then output annoak;
else if state=15 then output annohi;
else if state ne 72 then output annous;
run;

/* Create separate map data sets for Alaska, Hawaii, */
/* and the continental U.S. */
data us48 alaska hawaii;
set maps.states;
if state=2 then output alaska;
else if state=15 then output hawaii;
else if state ne 72 then output us48;
run;

/* Combine annotate observations with map observations. */
data allak;
set alaska annoak;
run;
data allhi;
set hawaii annohi;
run;
data allus;
set us48 annous;
run;

/* Project each data set separately. */
proc gproject data=allak out=projak
project=gnomon polelon=150 dupok;
id state;
run;

proc gproject data=allhi out=projhi dupok;
id state;
run;

proc gproject data=allus out=projus dupok;
id state;
run;

/* Adjust the coordinates for Alaska. */
data projak2;
set projak;
where density < 2;
x=(x-.75)*.50;
y=(y-.55)*.50;
run;

/* Adjust the coordinates for Hawaii. */
data projhi2;
set projhi;
where density < 4;
x=x-.12;
y=y-.20;
run;

/* Combine all map/anno data sets back together. */
/* Separate all map coordinates and all annotate */
/* coordinates. */
data map anno;
set projus projak2 projhi2;
if flag=1 then output anno;
else output map;
run;

/*******************/
/* Produce the MAP */
/*******************/

goptions reset=all;

proc gmap map=map data=map anno=anno;
id state;
choro state / coutline=black nolegend;
pattern1 c=cyan v=msolid r=50;
title1 'U.S. Map with Annotated State Capitals';
run;
quit;
Howard Schreier <hs AT dc-sug DOT org>
2007-07-25 18:56:32 UTC
Permalink
Renee --

I encourage you to turn this post into an article at sasCommunity, to
preserve its visibility.

http://sascommunity.org/wiki/Create_an_Article

On Wed, 25 Jul 2007 14:32:33 -0400, Renee Jaramillo
Post by Renee Jaramillo
I’ve run into this issue of needing to “move” Alaska and Hawaii to the
lower left corner of the graph. When I contacted SAS Tech Support, Sue
Morrison was kind enough to send me some sample code which I’ve included
below. Basically you separately project Alaska, Hawaii, and the contiguous
US, adjust the coordinates for Alaska and Hawaii to move to the lower left
corner, and then recombine all data before using GMAP. This example does
annotate and uses maps.states, but it would be easy to experiment and
substitute maps.counties.
Hope this helps,
Renee
= = = = = = = = = =
/* This program demonstrates how to apply annotation to */
/* a U.S. map which includes Alaska and Hawaii. AK and HI */
/* are moved beneath the continental U.S. */
/* Create a sample annotate data set of state capitals. */
data anno(drop=long lat capital);
length function style color $8;
retain xsys ysys '2' flag 1 when 'a';
/* Get city coordinates from the MAPS.USCITY data set. */
set maps.uscity(keep=state long lat city capital);
/* Label only the state capitals. */
where capital='Y';
/* Convert degrees to radians. */
x=(atan(1)/45)*long;
y=(atan(1)/45)*lat;
/* Create an observation to label the x,y coordinate */
/* with a red star. */
function='label';
style='special';
text='M';
color='red';
position='5';
size=1.5;
output;
run;
/* Separate the annotate data set into coordinates */
/* for Alaska, Hawaii, and the continental U.S. */
/* Annotate data sets will be projected with map */
/* data sets below. */
data annous annoak annohi;
set anno;
if state=2 then output annoak;
else if state=15 then output annohi;
else if state ne 72 then output annous;
run;
/* Create separate map data sets for Alaska, Hawaii, */
/* and the continental U.S. */
data us48 alaska hawaii;
set maps.states;
if state=2 then output alaska;
else if state=15 then output hawaii;
else if state ne 72 then output us48;
run;
/* Combine annotate observations with map observations. */
data allak;
set alaska annoak;
run;
data allhi;
set hawaii annohi;
run;
data allus;
set us48 annous;
run;
/* Project each data set separately. */
proc gproject data=allak out=projak
project=gnomon polelon=150 dupok;
id state;
run;
proc gproject data=allhi out=projhi dupok;
id state;
run;
proc gproject data=allus out=projus dupok;
id state;
run;
/* Adjust the coordinates for Alaska. */
data projak2;
set projak;
where density < 2;
x=(x-.75)*.50;
y=(y-.55)*.50;
run;
/* Adjust the coordinates for Hawaii. */
data projhi2;
set projhi;
where density < 4;
x=x-.12;
y=y-.20;
run;
/* Combine all map/anno data sets back together. */
/* Separate all map coordinates and all annotate */
/* coordinates. */
data map anno;
set projus projak2 projhi2;
if flag=1 then output anno;
else output map;
run;
/*******************/
/* Produce the MAP */
/*******************/
goptions reset=all;
proc gmap map=map data=map anno=anno;
id state;
choro state / coutline=black nolegend;
pattern1 c=cyan v=msolid r=50;
title1 'U.S. Map with Annotated State Capitals';
run;
quit;
Loading...