%let name=nfl_facebook_map; filename odsout '.'; /* Similar to this map: http://blogs.citypages.com/blotter/nfl%20fandom%20map.jpg http://common.ziffdavisinternet.com/util_get_image/31/0,1462,sz=1&i=312293,00.jpg */ proc sql noprint; /* Get a list of all the state/counties */ create table fan_data as select unique state, fipstate(state) as statecode, county from maps.uscounty; /* merge in the text county names */ create table fan_data as select fan_data.*, cntyname.countynm from fan_data left join maps.cntyname on fan_data.state=cntyname.state and fan_data.county=cntyname.county; quit; run; data fan_data; set fan_data; length favorite_team $3; favorite_team='???'; if statecode='VT' then favorite_team='NE'; if statecode='NH' then favorite_team='NE'; if statecode='ME' then favorite_team='NE'; if statecode='MA' then favorite_team='NE'; if statecode='RI' then favorite_team='NE'; if statecode='CT' then favorite_team='NE'; if statecode='CT' and county=1 then favorite_team='NYG'; if statecode='LA' then favorite_team='NO'; if statecode='MS' then favorite_team='NO'; if statecode='MS' and county in (33 9) then favorite_team='DAL'; if statecode='FL' then favorite_team='MIA'; if statecode='FL' and county in (31 109 121 23 107 19 125 7 3 89) then favorite_team='JAC'; if statecode='FL' and county in (127) then favorite_team='PIT'; if statecode='FL' and county in (97) then favorite_team='NYG'; if statecode='FL' and county in (35 15) then favorite_team='NE'; if statecode='FL' and county in (29) then favorite_team='GB'; if statecode='FL' and county in (77 37 45 13 33 113 63 133 91 131 59 5) then favorite_team='NO'; if statecode='FL' and county in (49 39) then favorite_team='DAL'; if statecode='FL' and county in (57 105 75 17 123 79 67 53 101 119 81 115 103) then favorite_team='TB'; if statecode='AL' then favorite_team='NO'; if statecode='AL' and county in (37) then favorite_team='PIT'; if statecode='AL' and county in (59 71 87 11 101 85) then favorite_team='DAL'; if statecode='AL' and county in (49 19 15 111 27 17 81 113 5) then favorite_team='ATL'; if statecode='GA' then favorite_team='ATL'; if statecode='GA' and county in (125 239) then favorite_team='???'; if statecode='GA' and county in (265 7) then favorite_team='NO'; if statecode='GA' and county in (39) then favorite_team='JAC'; if statecode='GA' and county in (179 65 259 37) then favorite_team='DAL'; if statecode='PA' then favorite_team='PIT'; if statecode='PA' and county in (103 89) then favorite_team='NYG'; if statecode='PA' and county in (71 29 11 107 91 45 37 25 95 77 17 101) then favorite_team='PHI'; if statecode='NJ' then favorite_team='NYG'; if statecode='NJ' and county in (5 1 21 9 11 33 15 7) then favorite_team='PHI'; if statecode='DE' then favorite_team='PHI'; if statecode='MD' then favorite_team='BAL'; if statecode='MD' and county in (1 23 43) then favorite_team='PIT'; if statecode='MD' and county in (21 31 33 17) then favorite_team='WAS'; if statecode='VA' then favorite_team='WAS'; if statecode='VA' and county in (1 17 163 125 29 9 19 31 37 111 117 143 83 81 183 67 89 800 93 141 63 53 135 7 49 149 550 199 101 97 700 195 5 45 23 161 155 197 77 35) then favorite_team='DAL'; if statecode='VA' and county in (175 27 51 105 169 167 191 173 185 21 91 71) then favorite_team='PIT'; if statecode='KY' then favorite_team='CIN'; if statecode='KY' and county in (195 159 13 95 19 127 35 157 105 55 115 71 75 133 145 183 163 29 229 215 211 5 153 25 131 235 197 165) then favorite_team='PIT'; if statecode='KY' and county in (83 39 219 141 177 227 9 3 171 213 53) then favorite_team='TEN'; if statecode='KY' and county in (221 47 33 107 7 149 59 225 233 101 91 27 231 85 31 61 179 93 123 99 87 217 167 237) then favorite_team='DAL'; if statecode='KY' and county in (143 139 147) then favorite_team='CHI'; if statecode='KY' and county in (63 189 109) then favorite_team='???'; if statecode='KY' and county in (207 1 57 169 155 111 185 223 103 41) then favorite_team='IND'; if statecode='SC' then favorite_team='PIT'; if statecode='SC' and county in (3) then favorite_team='ATL'; if statecode='SC' and county in (49) then favorite_team='NE'; if statecode='SC' and county in (5 11 1 65 21 87 23 69 33 67 31 41 27) then favorite_team='DAL'; if statecode='SC' and county in (83 91 57 25) then favorite_team='CAR'; if statecode='WV' then favorite_team='PIT'; if statecode='WV' and county in (37) then favorite_team='WAS'; if statecode='DC' then favorite_team='WAS'; if statecode='TX' then favorite_team='DAL'; if statecode='TX' and county in (301 155 269 345 263 81) then favorite_team='???'; if statecode='TX' and county in (385 457 241 407) then favorite_team='NO'; if statecode='TX' and county in (373 291 71 339 201 167 39 481 15 157) then favorite_team='HOU'; if statecode='OK' then favorite_team='DAL'; if statecode='AR' then favorite_team='DAL'; if statecode='AR' and county in (139 3 43 41 17) then favorite_team='NO'; if statecode='TN' then favorite_team='TEN'; if statecode='TN' and county in (139) then favorite_team='ATL'; if statecode='TN' and county in (19 73 171) then favorite_team='PIT'; if statecode='TN' and county in (157 47 95 91 163 179 59 29 67 121) then favorite_team='DAL'; if statecode='NC' then favorite_team='CAR'; if statecode='NC' and county in (187 29) then favorite_team='BAL'; if statecode='NC' and county in (87) then favorite_team='GB'; if statecode='NC' and county in (55) then favorite_team='WAS'; if statecode='NC' and county in (39 43) then favorite_team='ATL'; if statecode='NC' and county in (145 181 91 83 15 185 191 79 69 127 111 11 195 65 117 177 41 139 13 143 75 173) then favorite_team='DAL'; if statecode='NC' and county in (113 115 21 131 95 77 33 63 183 37 105 85 101 163 51 93 17 61 141 133 103 107 147 49 137 175) then favorite_team='PIT'; if statecode='NM' then favorite_team='DAL'; if statecode='NM' and county in (33) then favorite_team='DEN'; if statecode='NM' and county in (59) then favorite_team='CHI'; if statecode='NM' and county in (21 11) then favorite_team='???'; if statecode='AZ' then favorite_team='ARI'; if statecode='AZ' and county in (15 27 19 3 11) then favorite_team='DAL'; if statecode='CO' then favorite_team='DEN'; if statecode='CO' and county in (53) then favorite_team='DAL'; if statecode='WY' then favorite_team='DEN'; if statecode='KS' then favorite_team='KC'; if statecode='KS' and county in (23 181 199 75 203 101 135 109 193 153 39) then favorite_team='DEN'; if statecode='KS' and county in (129 189 175 119 57 47 187 67 81 55 93 155) then favorite_team='DAL'; if statecode='KS' and county in (207) then favorite_team='MIN'; if statecode='KS' and county in (71 83 65) then favorite_team='???'; if statecode='NE' then favorite_team='DEN'; if statecode='NE' and county in (165 7 69 5 75) then favorite_team='???'; if statecode='NE' and county in (147 127 131) then favorite_team='KC'; if statecode='NE' and county in (31 17 149 169 107 139 167 39 173 175 163 77 93 11 121 109 53 177 155 81 141) then favorite_team='GB'; if statecode='NE' and county in (89 27 179 21 59 83 73 97 25 125) then favorite_team='MIN'; if statecode='NE' and county in (51 85) then favorite_team='PIT'; if statecode='NE' and county in (143) then favorite_team='DET'; if statecode='NE' and county in (133) then favorite_team='STL'; if statecode='NE' and county in (43 15 91 113 9 115 71 183 119) then favorite_team='DAL'; if statecode='NE' and county in (35 95 151 67 185 23 37 55 153) then favorite_team='DAL'; if statecode='MO' then favorite_team='KC'; if statecode='MO' and county in (111) then favorite_team='CHI'; if statecode='MO' and county in (203 69 155) then favorite_team='DAL'; if statecode='MO' and county in (133 201 163 113 65 161 35 181 23 207 143 31 139 73 55 71 99 189 219 183 179 93 123 221 223 17 157 186 187) then favorite_team='STL'; if statecode='WA' then favorite_team='SEA'; if statecode='MN' then favorite_team='MIN'; if statecode='IA' then favorite_team='MIN'; if statecode='IA' and county in (55 61 13 113 51 177 11 95 135 123 97 45 103 31 139 163 107 183 87 111 115 57 153 121) then favorite_team='CHI'; if statecode='IA' and county in (5 43 65 19 75 157 99 101 179 185 145) then favorite_team='GB'; if statecode='IA' and county in (7 117 39 53 159 71 155 85 165 9) then favorite_team='DAL'; if statecode='IA' and county in (173 3 175 137 129 29) then favorite_team='KC'; if statecode='IA' and county in (105) then favorite_team='NE'; if statecode='IL' then favorite_team='CHI'; if statecode='IL' and county in (13 127) then favorite_team='DAL'; if statecode='IL' and county in (27 189 157 133 163 119 83 3) then favorite_team='STL'; if statecode='ND' then favorite_team='MIN'; if statecode='ND' and county in (43) then favorite_team='GB'; if statecode='ND' and county in (65) then favorite_team='PIT'; if statecode='ND' and county in (1 87 83) then favorite_team='???'; if statecode='SD' then favorite_team='MIN'; if statecode='SD' and county in (91 89 25 119 17) then favorite_team='???'; if statecode='SD' and county in (107 85) then favorite_team='DAL'; if statecode='SD' and county in (137) then favorite_team='KC'; if statecode='SD' and county in (19 121 95 93 81 55 75 47 113 7 71 33 103) then favorite_team='DEN'; if statecode='OH' then favorite_team='PIT'; if statecode='OH' and county in (7 123 143 147 175 65 91 137 3 55 133 11 85 9 75 169 35 93 101 77 139 33 151 153 5 103 43) then favorite_team='CLE'; if statecode='OH' and county in (17 135 145 1 131 141 107 149 37 109 61 25 21 23 47 57 113 165 15 71 27) then favorite_team='CIN'; if statecode='WI' then favorite_team='GB'; if statecode='MI' then favorite_team='DET'; if statecode='MI' and county in (95 153 109 43 53 131 3 41 61 83 71 13 103) then favorite_team='GB'; if statecode='MI' and county in (21 27) then favorite_team='CHI'; if statecode='OR' then favorite_team='OAK'; if statecode='ID' then favorite_team='DAL'; if statecode='ID' and county in (3) then favorite_team='DET'; if statecode='ID' and county in (71) then favorite_team='DEN'; if statecode='ID' and county in (33) then favorite_team='OAK'; if statecode='ID' and county in (23 25 15 85 61) then favorite_team='GB'; if statecode='ID' and county in (51) then favorite_team='PIT'; if statecode='ID' and county in (13 49 35 79 69 57 9 21 17 55) then favorite_team='SEA'; if statecode='NV' then favorite_team='DAL'; if statecode='NV' and county in (1 31 21 5) then favorite_team='SF'; if statecode='NV' and county in (19 510 27 15) then favorite_team='OAK'; if statecode='NV' and county in (9 17) then favorite_team='PIT'; if statecode='MT' then favorite_team='DAL'; if statecode='MT' and county in (25) then favorite_team='KC'; if statecode='MT' and county in (59 69 33) then favorite_team='???'; if statecode='MT' and county in (53 47) then favorite_team='SEA'; if statecode='MT' and county in (89 99) then favorite_team='PIT'; if statecode='MT' and county in (19 91 83 109) then favorite_team='MIN'; if statecode='MT' and county in (105 79 75 27 67 81 39 61) then favorite_team='GB'; if statecode='MT' and county in (29 63 7 43 93 49 31 45 5 51 21 17 87 103 3 111 37 97 95 9) then favorite_team='DEN'; if statecode='UT' then favorite_team='DAL'; if statecode='UT' and county in (7 39) then favorite_team='PIT'; if statecode='UT' and county in (1 21 25 31 55 37 19 15 47 13 49 9 43 29) then favorite_team='DEN'; if statecode='OR' and county in (15) then favorite_team='SF'; if statecode='OR' and county in (19) then favorite_team='PIT'; if statecode='OR' and county in (69) then favorite_team='GB'; if statecode='OR' and county in (45 23 55 21) then favorite_team='DAL'; if statecode='OR' and county in (17 13 65 7 57 9 67 47 5 27 43 71 53 41 3 49 59 61 63 1) then favorite_team='SEA'; if statecode='CA' then favorite_team='SF'; if statecode='CA' and county in (29) then favorite_team='DAL'; if statecode='CA' and county in (59 25 73 65) then favorite_team='SD'; if statecode='CA' and county in (71 27 37 51 107 111 83 3 35 93 91) then favorite_team='OAK'; if statecode='NY' then favorite_team='NYG'; if statecode='NY' and county in (117 99 13 9 97 29 3 55 63 73 69 123 37 121 51) then favorite_team='BUF'; if statecode='NY' and county in (101) then favorite_team='PIT'; if statecode='NY' and county in (59) then favorite_team='NYJ'; if statecode='IN' then favorite_team='IND'; if statecode='IN' and county in (111 73 89 127 91 141) then favorite_team='CHI'; if statecode='IN' and county in (29 155) then favorite_team='CIN'; if statecode='AK' then favorite_team='GB'; if statecode='AK' and county in (68) then favorite_team='KC'; if statecode='AK' and county in (185 188 270 20) then favorite_team='PIT'; if statecode='AK' and county in (150 16 13 201 130 280 220 232 110 282 100) then favorite_team='SEA'; if statecode='HI' then favorite_team='PIT'; run; data fan_data; set fan_data; length team_name $100; if favorite_team='ARI' then team_name='Arizona Cardinals'; if favorite_team='ATL' then team_name='Atlanta Falcons'; if favorite_team='BAL' then team_name='Baltimore Ravens'; if favorite_team='BUF' then team_name='Buffalo Bills'; if favorite_team='CAR' then team_name='Carolina Panthers'; if favorite_team='CHI' then team_name='Chicago Bears'; if favorite_team='CIN' then team_name='Cincinnati Bengals'; if favorite_team='CLE' then team_name='Cleveland Browns'; if favorite_team='DAL' then team_name='Dallas Cowboys'; if favorite_team='DEN' then team_name='Denver Broncos'; if favorite_team='DET' then team_name='Detroit Lions'; if favorite_team='GB' then team_name='Green Bay Packers'; if favorite_team='HOU' then team_name='Houston Texans'; if favorite_team='IND' then team_name='Indianapolis Colts'; if favorite_team='JAC' then team_name='Jacksonville Jaguars'; if favorite_team='KC' then team_name='Kansas City Chiefs'; if favorite_team='MIA' then team_name='Miami Dolphins'; if favorite_team='MIN' then team_name='Minnesota Vikings'; if favorite_team='NE' then team_name='New England Patriots'; if favorite_team='NO' then team_name='New Orleans Saints'; if favorite_team='NYG' then team_name='New York Giants'; if favorite_team='NYJ' then team_name='New York Jets'; if favorite_team='OAK' then team_name='Oakland Raiders'; if favorite_team='PHI' then team_name='Philadelphia Eagles'; if favorite_team='PIT' then team_name='Pittsburgh Steelers'; if favorite_team='SD' then team_name='San Diego Chargers'; if favorite_team='SEA' then team_name='Seattle Seahawks'; if favorite_team='SF' then team_name='San Francisco 49ers'; if favorite_team='STL' then team_name='St. Louis Rams'; if favorite_team='TB' then team_name='Tampa Bay Buccaneers'; if favorite_team='TEN' then team_name='Tennessee Titans'; if favorite_team='WAS' then team_name='Washington Redskins'; if favorite_team='???' then team_name='not enough data'; run; data fan_data; set fan_data; length my_html $300; my_html= 'title='||quote( propcase(trim(left(countynm)))||' county, '||trim(left(statecode))||'0d'x|| trim(left(team_name))); length l_html $100; l_html='title='||quote(trim(left(team_name))); run; libname robsmaps '../democd97'; data my_map; set robsmaps.uscounty (where=(density<=1)); run; proc gremove data=my_map (where=(statecode not in ('AK' 'HI'))) out=anno_outline; by state; id county; run; data anno_outline; set anno_outline; by state segment notsorted; length function $8 color $8; color='white'; style='mempty'; when='a'; xsys='2'; ysys='2'; if first.segment then function='poly'; else function='polycont'; run; goptions device=png; goptions xpixels=1200 ypixels=752; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="NFL Fans map (based on Facebook 'likes')") style=htmlblue; goptions gunit=pct htitle=4.5 ftitle="albany amt/bold" htext=1.9 ftext="albany amt/bold"; legend1 label=none position=(left middle) across=1 value=(height=1.9pct) shape=bar(.25in,.16in); pattern1 v=s c=cx8b291f; /* ari */ pattern2 v=s c=cxaf0c15; pattern3 v=s c=cx310f5a; pattern4 v=s c=cx9c0920; pattern5 v=s c=cx1c80df; /* car */ pattern6 v=s c=cx000060; pattern7 v=s c=cxd04a00; /* cin */ pattern8 v=s c=cx5b402b; pattern9 v=s c=cx6e6f92; pattern10 v=s c=cxf04c00; /* den */ pattern11 v=s c=cx19579d; pattern12 v=s c=cx195b00; pattern13 v=s c=cx981c15; pattern14 v=s c=cx808082; pattern15 v=s c=cx19636d; /* jac */ pattern16 v=s c=cx9e0900; pattern17 v=s c=cxe84b00; pattern18 v=s c=cx300071; pattern19 v=s c=cxb7b5b5; pattern20 v=s c=cx937b36; /* no */ pattern21 v=s c=cx0c0f66; pattern22 v=s c=cx3f9c09; pattern23 v=s c=cx000000; pattern24 v=s c=cx215b4a; pattern25 v=s c=cxfcbe00; /* pit */ pattern26 v=s c=cx0961d0; pattern27 v=s c=cx17468a; pattern28 v=s c=cxb11728; pattern29 v=s c=cx6d5803; pattern30 v=s c=cx980f06; /* tb */ pattern31 v=s c=cx5fa3ee; pattern32 v=s c=cx610b03; /* was */ title1 ls=1.5 "NFL Fans (based on Facebook)"; footnote1 c=gray j=r move=(-2,+0) link="https://www.facebook.com/notes/facebook-data-science/nfl-fans-on-facebook/10151298370823859" font="albany amt" ls=1.5 "Based on Facebook data, January 2013"; proc gmap data=fan_data map=my_map anno=anno_outline; id state county; choro favorite_team / midpoints= 'ARI' 'ATL' 'BAL' 'BUF' 'CAR' 'CHI' 'CIN' 'CLE' 'DAL' 'DEN' 'DET' 'GB' 'HOU' 'IND' 'JAC' 'KC' 'MIA' 'MIN' 'NE' 'NO' 'NYG' 'NYJ' 'OAK' 'PHI' 'PIT' 'SD' 'SEA' 'SF' 'STL' 'TB' 'TEN' 'WAS' legend=legend1 coutline=grayaa html=my_html html_legend=l_html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;