%let name=cooper; filename odsout '.'; data myanno; input zip ziptext $ 7-80; datalines; 27607 Raleigh 35203 Birmingham 36301 Dothan 28304 Fayetteville 28801 Asheville 55401 Minneapolis 40202 Louisville 45202 Cincinnati 74103 Tulsa 72201 Little Rock 77002 Houston 76701 Waco 79901 El Paso 70501 Lafayette 38801 Tupelo 31701 Albany 33122 Miami 32839 Orlando 37201 Nashville ; run; /* merge in the lat/long for each zipcode */ proc sql; create table myanno as select unique myanno.*, city, x as long, y as lat from myanno inner join sashelp.zipcode on myanno.zip=zipcode.zip; quit; run; /* convert degrees to radians */ data myanno; set myanno; st=zipstate(zip); state=stfips(st); anno_flag=1; run; data my_map; set mapsgfk.us_states (where=(statecode not in ('HI' 'AK' 'PR') and density<=3) drop=resolution); run; /* combine, project, separate */ data combined; set my_map myanno; run; proc gproject data=combined out=combined latlong eastlong degrees dupok; id state; run; data my_map myanno; set combined; if anno_flag=1 then output myanno; else output my_map; run; data myanno; set myanno; length function color $8 html $500; xsys='2'; ysys='2'; hsys='3'; when='A'; html= 'title='|| quote( 'City: '||trim(left(ziptext))||'0D'x|| 'Zipcode: '||trim(left(zip)))|| ' href="'||trim(left(lowcase(ziptext)))||'.htm"'; function='pie'; rotate=360; size=.6; position='5'; color='red'; style='psolid'; output; color='yellow'; style='pempty'; output; function='label'; size=1.75; color='black'; position='2'; style=''; text=trim(left(ziptext)); output; run; data my_data; input st $ 1-2; state=stfips(st); colorval=1; datalines; NC SC GA FL MS AL LA AR TX OK TN KY OH IO MN ; run; /* Now, create a 'centers' dataset with the estimated centers of each state, and then annotate the state abbreviation at the center of each state. */ %annomac; %centroid( my_map, centroid, state ); proc sql; create table state_name as select * from centroid where state in (select unique state from my_data); quit; run; data state_name; set state_name; length function color $8; xsys='2'; ysys='2'; hsys='3'; when='a'; function='label'; color='gray55'; size=2.75; position='5'; text=trim(left(fipstate(state))); run; data myanno; set state_name myanno; run; /* Define a template, to get the graphic above the map ... */ ods path work.template(update) sashelp.tmplmst; proc template; define style styles.cooper; parent = styles.minimal; /* Put the graphic above the title */ style Body from Document / prehtml="
"; /* replace color list with something, so that gray background is over-ridden, and white is used */ replace colors / "link1"=color_list("green"); end; run; goptions device=png; goptions xpixels=750 ypixels=550; goptions noborder; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Cooper Transportation Map - proof-of-concept") style=cooper; goptions cback=white ctext=cx75A1D0 ftext="albany amt" gunit=pct htext=4; pattern1 v=s c=cx75A1D0; title; footnote1 "Shipping Hub Locations"; footnote2 color=gray "(click 'Raleigh' to see routes)"; proc gmap data=my_data map=my_map anno=myanno all; id state; choro colorval / nolegend coutline=gray77 cempty=gray77 des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;