As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


US Maps with Alaska and Hawaii as Insets

From sasCommunity
Jump to: navigation, search

Problem: Create a map of the United States with Alaska and Hawaii appearing as insets (that is, differing from the rest of the map in position and scale).

According to Renee Jaramillo, who posted a solution (attributed to SAS Tech Support) "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". See the SAS-L post.

There is another way to get Alaska and Hawaii to appear in the lower left corner of the map. If you are willing to use an already projected map that has a bit less detail in the map borders, the US map data set in the MAPS library already has Alaska and Hawaii in the correct position.

This code is an easy way to produce an outline map of the US.

* reset all the graphics option;
goptions reset=all;

* specify a color for the one state that will be 'mapped';
pattern1 v=e c=blue;

* 
use the US map data set for both the DATA and MAP data sets
use one observation for the DATA (it will use the PATTERN specified above)
use the ALL option to display all the states (with Alaska and Hawaii)
use the COUTLINE option to specify a color that matches the PATTERN statement
;
proc gmap data=maps.us (obs=1) map=maps.us all;
id state;
choro state / discrete coutline=blue nolegend;
run;
quit;

Note: in V9.2, the US map data set also includes Puerto Rico. If you do not want Puerto Rico in the map, add a WHERE statement to PROC GMAP as follows.

proc gmap data=maps.us (obs=1) map=maps.us all;
id state;
choro state / discrete coutline=blue nolegend;
where state ne 72;
run;
quit;