%let name=nc; filename odsout '.'; goptions reset=global; proc sql; create table my_map as select * from maps.county where state eq stfips('NC'); quit; run; proc gproject data=my_map out=my_map dupok; id state; run; /* Create a 'shadow' outline of the map */ data anno_shadow; set my_map; orig_order+1; run; proc sort data=anno_shadow out=anno_shadow; by county segment orig_order; run; proc gremove data=anno_shadow out=anno_shadow; by county; id county; run; data work.anno_shadow; length COLOR FUNCTION $ 8; retain FX FY FUNCTION; set anno_shadow; by county segment; xsys='2'; ysys='2'; color='black'; size=1.75; when='B'; style='msolid'; if first.segment then do; FUNCTION = 'poly'; FX = X; FY = Y; end; else if FUNCTION ^= ' ' then do; if X = . then do; X = FX; Y = FY; output; FUNCTION = ' '; end; else FUNCTION = 'polycont'; end; if FUNCTION ^= ' ' then do; output; if last.segment then do; X = FX; Y = FY; output; end; end; run; /* Give a little x & y offset, so it will look like a shadow */ data anno_shadow; set anno_shadow; x=x+.0004; y=y-.0006; run; data a; input county_name $ 1-15 region $ 17-27; state=stfips('NC'); region=upcase(region); datalines; Alamance Triad Alexander Charlotte Alleghany Western Anson Charlotte Ashe Western Avery Western Beaufort Eastern Bertie Eastern Bladen Eastern Brunswick Eastern Buncombe Western Burke Western Cabarrus Charlotte Caldwell Western Camden Eastern Carteret Eastern Caswell Triad Catawba Charlotte Chatham Triangle Cherokee Western Chowan Eastern Clay Western Cleveland Charlotte Columbus Eastern Craven Eastern Cumberland Eastern Currituck Eastern Dare Eastern Davidson Triad Davie Triad Duplin Eastern Durham Triangle Edgecombe Eastern Forsyth Triad Franklin Triangle Gaston Charlotte Gates Eastern Graham Western Granville Triangle Greene Eastern Guilford Triad Halifax Eastern Harnett Triangle Haywood Western Henderson Western Hertford Eastern Hoke Eastern Hyde Eastern Iredell Charlotte Jackson Western Johnston Triangle Jones Eastern Lee Triangle Lenoir Eastern Lincoln Charlotte Mc Dowell Western Macon Western Madison Western Martin Eastern Mecklenburg Charlotte Mitchell Western Montgomery Triad Moore Triangle Nash Eastern New Hanover Eastern Northampton Eastern Onslow Eastern Orange Triangle Pamlico Eastern Pasquotank Eastern Pender Eastern Perquimans Eastern Person Triangle Pitt Eastern Polk Western Randolph Triad Richmond Eastern Robeson Eastern Rockingham Triad Rowan Charlotte Rutherford Western Sampson Eastern Scotland Eastern Stanly Charlotte Stokes Triad Surry Triad Swain Western Transylvania Western Tyrrell Eastern Union Charlotte Vance Triangle Wake Triangle Warren Triangle Washington Eastern Watauga Western Wayne Eastern Wilkes Western Wilson Eastern Yadkin Triad Yancey Western ; run; /* Create a separate value for each variable (could have been done using 'proc transpose' instead, I suppose, but wanted to keep this straightforward and easy to follow. */ data a; set a; if region eq 'EASTERN' then EASTERN=1; if region eq 'TRIANGLE' then TRIANGLE=1; if region eq 'TRIAD' then TRIAD=1; if region eq 'CHARLOTTE' then CHARLOTTE=1; if region eq 'WESTERN' then WESTERN=1; run; /* Now, lookup numeric county fips code for these county names */ proc sql; create table a as select a.*, cntyname.county from a left join maps.cntyname on a.state=cntyname.state and upcase(a.county_name)=cntyname.countynm; quit; run; proc sort data=a out=a; by region; run; data a; set a; length html $500; html='title='|| quote( trim(left(county_name))||' County'||' ' ) ||' '|| 'href="fbi.htm"'; run; /* 'County Name: '||trim(left(county_name))||'0D'x|| 'County FIPS Code: '||trim(left(county))||' ' */ /* Create 2 colored areas to annotate behind the map */ data anno_eastern; length function style color $10; retain xsys '3' ysys '3' when 'b' style 'solid'; function='move'; x=0; y=61; output; function='bar'; x=100; y=100; color='cx253494'; output; orig_red= input('74',hex2.); orig_green=input('a9',hex2.); orig_blue= input('cf',hex2.); do i=62 to 2 by -2; count+1; function='move'; x=0; y=i; output; function='bar'; x=100; y=i-2; percent=(count-1)/(62/2); red=orig_red + ( (256-orig_red) * percent ); green=orig_green + ( (256-orig_green) * percent ); blue=orig_blue + ( (256-orig_blue) * percent ); rgb=put(red,hex2.)||put(green,hex2.)||put(blue,hex2.); color="cx"||rgb; output; end; run; data anno_triangle; length function style color $10; retain xsys '3' ysys '3' when 'b' style 'solid'; function='move'; x=0; y=61; output; function='bar'; x=100; y=100; color='cxfdae61'; output; orig_red= input('fd',hex2.); orig_green=input('bb',hex2.); orig_blue= input('84',hex2.); do i=62 to 2 by -2; count+1; function='move'; x=0; y=i; output; function='bar'; x=100; y=i-2; percent=(count-1)/(62/2); red=orig_red + ( (256-orig_red) * percent ); green=orig_green + ( (256-orig_green) * percent ); blue=orig_blue + ( (256-orig_blue) * percent ); rgb=put(red,hex2.)||put(green,hex2.)||put(blue,hex2.); color="cx"||rgb; output; end; run; data anno_triad; length function style color $10; retain xsys '3' ysys '3' when 'b' style 'solid'; function='move'; x=0; y=61; output; function='bar'; x=100; y=100; color='cx006837'; output; orig_red= input('ad',hex2.); orig_green=input('dd',hex2.); orig_blue= input('8e',hex2.); do i=62 to 2 by -2; count+1; function='move'; x=0; y=i; output; function='bar'; x=100; y=i-2; percent=(count-1)/(62/2); red=orig_red + ( (256-orig_red) * percent ); green=orig_green + ( (256-orig_green) * percent ); blue=orig_blue + ( (256-orig_blue) * percent ); rgb=put(red,hex2.)||put(green,hex2.)||put(blue,hex2.); color="cx"||rgb; output; end; run; data anno_charlotte; length function style color $10; retain xsys '3' ysys '3' when 'b' style 'solid'; function='move'; x=0; y=61; output; function='bar'; x=100; y=100; color='cxfeb24c'; output; orig_red= input('fe',hex2.); orig_green=input('c4',hex2.); orig_blue= input('4f',hex2.); do i=62 to 2 by -2; count+1; function='move'; x=0; y=i; output; function='bar'; x=100; y=i-2; percent=(count-1)/(62/2); red=orig_red + ( (256-orig_red) * percent ); green=orig_green + ( (256-orig_green) * percent ); blue=orig_blue + ( (256-orig_blue) * percent ); rgb=put(red,hex2.)||put(green,hex2.)||put(blue,hex2.); color="cx"||rgb; output; end; run; data anno_western; length function style color $10; retain xsys '3' ysys '3' when 'b' style 'solid'; function='move'; x=0; y=61; output; function='bar'; x=100; y=100; color='cxb30000'; output; orig_red= input('fe',hex2.); orig_green=input('e8',hex2.); orig_blue= input('c8',hex2.); do i=62 to 2 by -2; count+1; function='move'; x=0; y=i; output; function='bar'; x=100; y=i-2; percent=(count-1)/(62/2); red=orig_red + ( (256-orig_red) * percent ); green=orig_green + ( (256-orig_green) * percent ); blue=orig_blue + ( (256-orig_blue) * percent ); rgb=put(red,hex2.)||put(green,hex2.)||put(blue,hex2.); color="cx"||rgb; output; end; run; GOPTIONS DEVICE=gif; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" style=minimal gtitle nogfootnote ; goptions border; goptions xpixels=800 ypixels=375; pattern1 v=s c=cxd9f0d3; /* other counties are light green */ pattern2 v=s c=red; /* counties of interest are red */ goptions htitle=10pct ftitle="arial/bo" ctitle=white ftext="arial"; title j=l " EASTERN"; footnote j=r "Based on maps in " link="http://www.businessnc.com/archives/2004/03/regional_report.html" "'Business North Carolina'" link="" " magazine"; proc gmap data=a map=my_map all anno=anno_eastern; id county; choro EASTERN / anno=anno_shadow nolegend discrete missing coutline=grayff cempty=lig html=html des="" name="&name"; run; title j=l " TRIANGLE"; proc gmap data=a map=my_map all anno=anno_triangle; id county; choro TRIANGLE / anno=anno_shadow nolegend discrete missing coutline=grayff cempty=lig html=html des="" name="&name"; run; title j=l " TRIAD"; proc gmap data=a map=my_map all anno=anno_triad; id county; choro TRIAD / anno=anno_shadow nolegend discrete missing coutline=grayff cempty=lig html=html des="" name="&name"; run; title j=l " CHARLOTTE"; proc gmap data=a map=my_map all anno=anno_charlotte; id county; choro CHARLOTTE / anno=anno_shadow nolegend discrete missing coutline=grayff cempty=lig html=html des="" name="&name"; run; title j=l " WESTERN"; proc gmap data=a map=my_map all anno=anno_western; id county; choro WESTERN / anno=anno_shadow nolegend discrete missing coutline=grayff cempty=lig html=html des="" name="&name"; run; /* proc print data=a; run; */ quit; ODS HTML CLOSE; ODS LISTING;