%let name=nc_emissions_inspection; filename odsout '.'; /* User-defined format to make the numeric categories print as descriptive text values */ proc format; value catfmt 1 = "Emissions testing (OBD) and safety inspections required for cars and light-duty trucks" 0 = "Safety inspections only required for cars and trucks" ; run; data my_data; input county_name $ 1-15 category; statecode='NC'; datalines; Alamance 1 Alexander 0 Alleghany 0 Anson 0 Ashe 0 Avery 0 Beaufort 0 Bertie 0 Bladen 0 Brunswick 0 Buncombe 1 Burke 0 Cabarrus 1 Caldwell 0 Camden 0 Carteret 0 Caswell 0 Catawba 0 Chatham 0 Cherokee 0 Chowan 0 Clay 0 Cleveland 0 Columbus 0 Craven 0 Cumberland 1 Currituck 0 Dare 0 Davidson 1 Davie 0 Duplin 0 Durham 1 Edgecombe 0 Forsyth 1 Franklin 1 Gaston 1 Gates 0 Graham 0 Granville 0 Greene 0 Guilford 1 Halifax 0 Harnett 0 Haywood 0 Henderson 0 Hertford 0 Hoke 0 Hyde 0 Iredell 1 Jackson 0 Johnston 1 Jones 0 Lee 1 Lenoir 0 Lincoln 1 McDowell 0 Macon 0 Madison 0 Martin 0 Mecklenburg 1 Mitchell 0 Montgomery 0 Moore 0 Nash 0 New Hanover 1 Northampton 0 Onslow 1 Orange 0 Pamlico 0 Pasquotank 0 Pender 0 Perquimans 0 Person 0 Pitt 0 Polk 0 Randolph 1 Richmond 0 Robeson 0 Rockingham 1 Rowan 1 Rutherford 0 Sampson 0 Scotland 0 Stanly 0 Stokes 0 Surry 0 Swain 0 Transylvania 0 Tyrrell 0 Union 1 Vance 0 Wake 1 Warren 0 Washington 0 Watauga 0 Wayne 0 Wilkes 0 Wilson 0 Yadkin 0 Yancey 0 ; run; proc sql noprint; select count(*) into :count separated by ' ' from my_data where category=1; quit; run; /* Merge in the numeric county number, so you'll have something that matches with the map */ proc sql noprint; create table my_data as select unique my_data.*, us_counties_attr.county from my_data left join mapsgfk.us_counties_attr on my_data.statecode=us_counties_attr.statecode and my_data.county_name=us_counties_attr.idname; quit; run; data my_data; set my_data; length html $200; html='title='||quote(trim(left(county_name))||' County')|| ' href='||quote('https://www.ncdot.gov/dmv/title-registration/emissions-safety/Pages/inspection-stations.aspx?term='||trim(left(county_name))||'&field=county'); run; /* get the map */ data my_map; set mapsgfk.us_counties (where=(statecode='NC' and density<=3)); county_name=idname; run; proc gproject data=my_map out=my_map latlong eastlong degrees dupok; id state; run; /* Create a 'shadow' outline of the map */ data anno_shadow; set my_map; by county segment; length color function $8; xsys='2'; ysys='2'; when='B'; color='gray33'; style='msolid'; if first.county or first.segment then function='poly'; else function='polycont'; run; /* Give a little x & y offset, so it will look like a shadow */ data anno_shadow; set anno_shadow; x=x+.0002; y=y-.0001; run; data anno_outdated; xsys='3'; ysys='3'; hsys='3'; when='a'; function='label'; style='albany amt/bold'; size=15; angle=45; color='Aff000077'; x=50; y=60; position='5'; text='outdated'; output; run; goptions device=png; goptions xpixels=1000 ypixels=600; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="North Carolina Vehicle Inspections Map") style=htmlblue; goptions gunit=pct htitle=5.5 htext=3.8 ftitle="albany amt/bold" ftext="albany amt/bold"; /* these patterns are assigned in the same order as the midpoints= are specified */ pattern1 v=s c=cx0095da; pattern2 v=s c=cxfffcd6; legend1 label=none position=(bottom center) across=1 shape=bar(.18in,.18in) value=(justify=left font="albany amt"); title1 ls=1.5 font="albany amt/bold" height=5.5pct link="https://deq.nc.gov/about/divisions/air-quality/motor-vehicles-air-quality/inspection-maintenance-program/general-information#G1" "Emissions Testing and Safety Inspections"; title2 ls=.5 font="albany amt/bold" height=5.5pct "for Motor Vehicles"; title3 a=90 h=1 " "; title4 a=-90 h=1 " "; footnote1 h=2.5 j=l move=(+6,+0) color=gray99 "In all 100 counties, cars and light-duty trucks are required to get an annual safety inspection if they are"; footnote2 h=2.5 j=l move=(+6,+0) color=gray99 "less than 35 years old. In the blue-shaded counties, 1996 and newer cars and light-duty trucks also are"; footnote3 h=2.5 j=l move=(+6,+0) color=gray99 link='https://deq.nc.gov/about/divisions/air-quality/motor-vehicles-air-quality/inspection-maintenance-program/3-year-70000-miles-exemption-calculator' "required to get an annual emissions inspection (vehicles < 3 years old with < 70k miles are exempt)." j=r "As of Dec 1, 2018 "; footnote4 h=1.5 " "; proc gmap data=my_data map=my_map all; note move=(6.5,38) font='albany amt' h=2.5 "&count counties require emission inspection"; format category catfmt.; id statecode county; choro category / discrete midpoints= 1 0 anno=anno_shadow cdefault=white coutline=gray55 legend=legend1 html=html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;