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;