Maps Online >Resources SAS logo
Feedback   

Sample Data
Sample Programs
Tools
Useful Links

//*******************************************************************\
| Copyright (C) 2003 by SAS Institute Inc., Cary, NC, USA.          |
|                                                                   |
| SAS (R) is a registered trademark of SAS Institute Inc.           |
|                                                                   |
| SAS Institute does not assume responsibility for the accuracy of  |
| any material presented in this file.                              |
\*******************************************************************/
 
/* drawing boxes around Hawaii, Alaska and Puerto Rico in US map   */
 
/********************************************************************
* This SAS program an example of drawing boxes around              *
* those islands that were moved from their actual location.        *
********************************************************************/
 
goptions reset=goptions;
 
/********************************************************************
* determine the range of the islands                               *
********************************************************************/
 
proc means min max data=maps.us(where=(state=2))noprint;
var x y;output out =ak min=minx miny max=maxx maxy;
run;
 
proc means min max data=maps.us(where=(state=15))noprint;
var x y;output out =hi min=minx miny max=maxx maxy;
run;
 
proc means min max data=maps.us(where=(state=72))noprint;
var x y;output out =pr min=minx miny max=maxx maxy ;
run;
 
/********************************************************************
* determine coordinates for Hawaii boxed                           *
********************************************************************/
data boxhi;
retain state 99 segment 2;
set hi;
x=minx-0.005; y=-0.144; output;
x=minx-0.005; y=maxy+0.005; output;
x=maxx+0.005; y=maxy+0.005; output;
x=maxx+0.005; y=miny-0.005; output;
x=-0.186; y=miny-0.005; output;
x=-0.186; y=-0.176; output;
x=minx-0.005; y=-0.144; output;
x=-0.186; y=-0.176; output;
x=-0.186; y=miny-0.005; output;
x=maxx+0.005; y=miny-0.005; output;
x=maxx+0.005; y=maxy+0.005; output;
x=minx-0.005; y=maxy+0.005; output;
x=minx-0.005; y=-0.144; output;
run;
 
/********************************************************************
* using Hawaii points to fix Alaska                                *
********************************************************************/
data hik;
set boxhi(keep=x y);
point=_n_;
if point=1 then do;
hix1=x; hiy1=y;
end;
else if point=5 then do;
hix5=x; hiy5=y;
end;
else if point=6 then do;
hix6=x; hiy6=y;
output;
end;
retain hix1 hix5 hix6 hiy1 hiy5 hiy6;
run;
 
/********************************************************************
* determine coordinates for Alaska boxed                           *
********************************************************************/
data boxak;
retain state 99 segment 1;
set ak;
if _n_=1 then set hik;
retain hix1 hix5 hix6 hiy1 hiy5 hiy6;
x=minx-.005; y=miny-0.005; output;
x=minx-.005; y=maxy+.005; output;
x=-0.270; y=maxy+.005; output;
x=-0.270; y=hiy1; output;
x=hix1; y=hiy1; output;
x=hix6; y=hiy6; output;
x=hix5; y=hiy5; output;
x=minx-.005; y=miny-0.005; output;
x=hix5; y=hiy5; output;
x=hix6; y=hiy6; output;
x=hix1; y=hiy1; output;
x=-0.270; y=hiy1; output;
x=-0.270; y=maxy+.005; output;
x=minx-.005; y=maxy+.005; output;
x=minx-.005; y=miny-0.005; output;
run;
 
/********************************************************************
* determine coordinates for Puerto Rico boxed                      *
********************************************************************/
data boxpr;
retain state 99 segment 3;
set pr;
x=minx-0.005; y=miny-0.005; output;
x=minx-0.005; y=maxy+0.005; output;
x=maxx+0.005; y=maxy+0.005; output;
x=maxx+0.005; y=miny-0.005; output;
x=minx-0.005; y=miny-0.005; output;
x=maxx+0.005; y=miny-0.005; output;
x=maxx+0.005; y=maxy+0.005; output;
x=minx-0.005; y=maxy+0.005; output;
x=minx-0.005; y=miny-0.005; output;
run;
 
/********************************************************************
* append the box-data to the map-data                              *
********************************************************************/
data hin;
set maps.us(where=(state=15)) boxhi;
run;
 
proc gmap map=hin data=hin;
id state; choro state/discrete;
run;
 
data akn;
set maps.us(where=(state=2)) boxak;
run;
 
data prrn;
set maps.us(where=(state=72)) boxpr;
run;
 
data usbox;
set maps.us(where=(state not in(2 15 72))) akn hin prrn;
run;
 
filename gsasfile  "usbox.gif";
 
goptions dev=gif transparency gaccess=gsasfile
goutmode=replace xpixels=600 ypixels=400
ftext=simplex gunit=pct htext=.15in
ctext=black;
 
proc gmap map=usbox data=usbox;
id state; choro state/discrete;
title;
run;