%let name=food_banks_ce_nc; filename odsout '.'; /* Using data from: http://www.foodbankcenc.org Branches: http://www.foodbankcenc.org/site/PageServer?pagename=branch_durham http://www.foodbankcenc.org/site/PageServer?pagename=branch_greenville http://www.foodbankcenc.org/site/PageServer?pagename=Branch_NewBern http://www.foodbankcenc.org/site/PageServer?pagename=branch_raleigh http://www.foodbankcenc.org/site/PageServer?pagename=branch_sandhills http://www.foodbankcenc.org/site/PageServer?pagename=branch_wilmington */ data branches; length branch $20 whole_address $100 address $70 city $50 statecode $2; infile datalines dlm=':'; input branch whole_address; address=trim(left(scan(whole_address,1,','))); city=trim(left(scan(whole_address,2,','))); statecode=trim(left(scan(whole_address,3,','))); zip=.; zip=scan(whole_address,4,','); flag=1; datalines; durham:2700 Angier Avenue, Durham, NC, 27703 greenville:1712 Union Street, Greenville, NC, 27834 NewBern:205 South Glenburnie Road, New Bern, NC, 28560 raleigh:1924 Capital Boulevard, Raleigh, NC, 27604 sandhills:195 Sandy Avenue, Southern Pines, NC, 28387 wilmington:1314 Marstellar Street, Wilmington, NC, 28401 ; run; data branches; set branches; length branch_propcase $50; branch_propcase=propcase(branch); if branch_propcase='Newbern' then branch_propcase='New Bern'; run; libname lookup '\\migvm01\GEOCODE lookup data\2017 US streets (9.4)'; proc geocode out=branches (rename=(x=long y=lat)) data=branches method=street lookupstreet=lookup.usm lookupstatevar=statecode; run; data nc_map; set mapsgfk.us_counties (where=(statecode='NC' and density<=2) drop=resolution); run; data combined; set nc_map branches; run; proc gproject data=combined out=combined latlong eastlong degrees; id statecode county; run; data nc_map branches; set combined; if flag=1 then output branches; else output nc_map; run; data branches; set branches; length function $8 color $8; xsys='2'; ysys='2'; hsys='3'; when='a'; function='pie'; size=1.8; rotate=360; style='psolid'; /*color='cx835d3b';*/ color='yellow'; output; length html $300; html= 'title='||quote(trim(left(branch_propcase))||' distribution center')|| ' href='||quote('http://www.foodbankcenc.org/site/PageServer?pagename=branch_'||trim(left(branch))); style='pempty'; color='cx4c2d00'; output; run; data counties; length county_name $50 serviced_by $50; infile datalines dlm=':'; input county_name serviced_by; statecode='NC'; state=.; state=stfips(statecode); datalines; Chatham:durham Durham:durham Granville:durham Orange:durham Person:durham Vance:durham Carteret:greenville Craven:greenville Edgecombe:greenville Greene:greenville Jones:greenville Lenoir:greenville Onslow:greenville Pamlico:greenville Pitt:greenville Wilson:greenville Carteret:NewBern Craven:NewBern Jones:NewBern Onslow:NewBern Pamlico:NewBern Duplin:raleigh Franklin:raleigh Halifax:raleigh Harnett:raleigh Johnston:raleigh Nash:raleigh Sampson:raleigh Wake:raleigh Warren:raleigh Wayne:raleigh Lee:sandhills Moore:sandhills Richmond:sandhills Scotland:sandhills Brunswick:wilmington Columbus:wilmington New Hanover:wilmington Pender:wilmington ; run; data counties; set counties; length serviced_by_propcase $50; serviced_by_propcase=propcase(serviced_by); if serviced_by_propcase='Newbern' then serviced_by_propcase='New Bern'; length my_html $300; my_html='title='||quote(trim(left(county_name))||' county'); run; /* look up the county fips code */ proc sql noprint; create table counties as select counties.*, us_counties_attr.county from counties left join mapsgfk.us_counties_attr on (counties.statecode=us_counties_attr.statecode) and (counties.county_name=us_counties_attr.idname); quit; run; %annomac; %centroid(nc_map,nc_centroids,state county,segonly=1); data nc_centroids; set nc_centroids; /* move Johnston county's centroid a little */ if county=101 then do; x=x-.0008; y=y-.001; end; run; proc sql noprint; /* merge in coordinate of county centroids */ create table anno_lines as select unique counties.*, nc_centroids.x as end_x, nc_centroids.y as end_y from counties left join nc_centroids on counties.state=nc_centroids.state and counties.county=nc_centroids.county; /* merge in coordinate of distribution centers */ create table anno_lines as select unique anno_lines.*, branches.x as start_x, branches.y as start_y from anno_lines left join branches on anno_lines.serviced_by=branches.branch; quit; run; data anno_lines; set anno_lines; length function $8 color $8; xsys='2'; ysys='2'; hsys='3'; when='a'; function='move'; x=start_x; y=start_y; output; function='draw'; x=end_x; y=end_y; color='cx4c2d00'; size=.01; output; run; data anno_all; set anno_lines branches; run; goptions device=png; goptions xpixels=1000 ypixels=500; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Food Bank of Central & Eastern North Carolins (FBCENC)") style=htmlblue; goptions gunit=pct htitle=5.0 htext=2.8 ftitle="albany amt/bold" ftext="albany amt"; goptions ctext=gray33; pattern1 v=s c=cxfbb4ae; pattern2 v=s c=cxb3cde3; pattern3 v=s c=cxb3cde3; pattern4 v=s c=cxccebc5; pattern5 v=s c=cxdecbe4; pattern6 v=s c=cxfed9a6; legend1 label=(position=top 'Serviced by Distribution Center') position=(bottom left inside) mode=share across=3 offset=(5,5) shape=bar(.15in,.15in); title1 link='http://www.foodbankcenc.org' ls=1.5 "Food Bank of Central & Eastern North Carolina (FBCENC)"; title2 a=90 h=2 ' '; title3 a=-90 h=2 ' '; proc gmap data=counties map=nc_map anno=anno_all all; id statecode county; choro serviced_by_propcase / cdefault=grayfc cempty=graycc coutline=gray88 legend=legend1 html=my_html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;