%let name=waffle_house_locations; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* Couldn't figure out an easy way to scrape the data from: https://locations.wafflehouse.com/ So I bought the data from: https://www.scrapehero.com/store/product/waffle-house-store-locations-in-the-usa/ */ proc import out=my_data datafile="../data_vault/Waffle_House_USA.csv" dbms=csv replace; getnames=yes; datarow=2; guessingrows=all; run; /* proc import made these character, but we need numeric variables */ data my_data (drop = latitude longitude); set my_data; long=.; lat=.; long=longitude; lat=latitude; run; data my_map; set mapsgfk.us_states (where=(statecode not in ('AK' 'HI') and density<=3)); run; proc gproject data=my_map out=my_map latlong eastlong degrees dupok parmout=projparm; id statecode; run; proc gproject data=my_data out=my_data latlong eastlong degrees dupok parmin=projparm parmentry=my_map; id; run; proc sql noprint; select count(*) format=comma12.0 into :count separated by ' ' from my_data; select count(*) format=comma12.0 into :nccount separated by ' ' from my_data where state='NC'; quit; run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Waffle House Locations") style=htmlblue; ods graphics / noscale /* if you don't use this option, the text will be resized */ imagefmt=png imagename="&name" noborder; title1 c=gray33 h=24pt "&count Waffle House Locations"; title2 c=gray h=15pt "Data snapshot from scrapehero.com: Dec 18, 2019"; ods graphics / width=1000px height=700px; proc sgmap mapdata=my_map (drop = lat long) plotdata=my_data noautolegend; choromap / mapid=statecode lineattrs=(color=grayaa); scatter x=x y=y / markerattrs=(size=3px color=red symbol=circlefilled); run; %annomac; %centroid(my_map,map_centers,state,segonly=1); proc sql noprint; create table state_data as select unique state as statecode, count(*) as state_count from my_data group by state; /* merge in the state centroid */ create table state_data as select unique state_data.*, map_centers.x, map_centers.y from state_data left join map_centers on state_data.statecode=fipstate(map_centers.state); quit; run; ods html anchor='totals'; ods graphics / width=1000px height=700px; proc sgmap mapdata=my_map (drop = lat long) plotdata=state_data noautolegend; choromap / mapid=statecode lineattrs=(color=grayaa); text x=x y=y text=state_count / textattrs=(color=red size=12pt); run; title1 c=gray33 h=24pt "&nccount Waffle House Locations in North Carolina"; title2 c=gray h=15pt "Data snapshot from scrapehero.com: Dec 18, 2019"; ods html anchor='nc'; ods graphics / width=1200px height=600px; ods graphics / imagemap tipmax=2500; data nc_map; set mapsgfk.us_states (where=(statecode='NC')); run; data my_data; set my_data; length my_url $300; my_url='http://www.google.com/search?&q=waffle house +'||trim(left(address)); run; proc sgmap mapdata=nc_map plotdata=my_data (where=(state='NC')) noautolegend; esrimap url="http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map"; choromap / mapid=statecode lineattrs=(color=gray11); scatter x=long y=lat / markerattrs=(size=8px color=red symbol=circlefilled) /* you'll need 9.4m6a for the tips= and url= option */ tips=(address) url=my_url; run; quit; ODS HTML CLOSE; ODS LISTING;