/* Step 1 */ goptions rotate=landscape htext=3 pct ftext=swissb; /* 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; /* Step 2 */ /* Project the map of western states. */ proc gproject data=swest out=swest; id state county; run; /* Step 3 */ /* Create a data set with only state borders. */ proc gremove data=swest out=stborder; by state; id county; run; /* Step 4 */ /* 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; /* Step 5 */ /* Create an Annotate data set to draw */ /* state borders. */ data annost; set stborder; by state segment; retain size 8 /* 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; /* Step 6 */ data annoreg; set regbordr; by region segment; retain size 8 /* 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; /* Step 7 */ /* Combine the two Annotate data sets. */ data annoboth; set annost annoreg; run; /* Step 8 */ /* Create the map, using the Annotate facility to */ /* draw state and region outlines. */ title h=8 pct 'Western Conservation Regions'; 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; pattern1 v=s c=green; pattern2 v=s c=blue; pattern3 v=s c=red; pattern4 v=s c=magenta; pattern5 v=s c=cyan; run;