%let name=passport_ranking_2017; filename odsout '.'; /* Data from: https://www.passportindex.org/byRank.php Related article: http://www.cnn.com/travel/article/global-passport-index-singapore/index.html */ filename datafile "passport_ranking_2017.txt"; data my_data (keep = country visa_free_score); length junk1 country blankline score_line $80; infile datafile lrecl=80 pad; input junk1 $ 1-80; input country $ 1-80; input blankline $ 1-80; input score_line $ 1-80; visa_free_score=.; visa_free_score=scan(score_line,1,'V'); run; data my_map; set mapsgfk.world (where=(density<=1 and idname^='Antarctica') drop=resolution); country=idname; run; /* Change data names to match the map names */ data my_data; set my_data; country=propcase(country); country=tranwrd(country,' And ',' and '); country=tranwrd(country,' The ',' the '); country=tranwrd(country,' Of ',' of '); if country='Bolivia' then country='Bolivia, Plurinational State of'; if country='Brunei' then country='Brunei Darussalam'; if country='Congo (Dem. Rep.)' then country='Congo, the Democratic Republic of the'; if country="Cote D'ivoire (Ivory Coast)" then country="Ivory Coast"; if country="United States of America" then country="United States"; if country='Congo, the Democratic Republic of the' then country='Democratic Republic of Congo'; if country='Czechia' then country='Czech Republic'; if country="Macedonia (Fyrom)" then country="Macedonia"; if country="Micronesia" then country="Micronesia, Federated States of"; if country="Myanmar [burma]" then country="Myanmar"; if country='Samoa' then country='American Samoa'; if country="Tanzania" then country="Tanzania, United Republic of"; if country="Taiwan" then country="Taiwan, Province of China"; if country="Palestinian Territories" then country="Palestinian Territory, Occupied"; if country="St. Vincent and the Grenadines" then country="Saint Vincent and the Grenadines"; if country='Timor-Leste' then country='Timor Leste'; if country='Venezuela' then country='Venezuela, Bolivarian Republic of'; if country='' then country=''; /* if country='Iran' then country='Iran, Islamic Republic of'; if country="Laos" then country="Lao People's Democratic Republic"; if country="Syria" then country="Syrian Arab Republic"; if country="Moldova" then country="Moldova, Republic of"; if country="" then country=""; */ run; /* Merge in the 2-character country code */ proc sql noprint; create table my_data as select my_data.*, world_attr.isoalpha2 from my_data left join mapsgfk.world_attr on my_data.country=world_attr.idname; quit; run; data my_data; set my_data; length my_html $300; my_html= 'title='||quote( trim(left(country))||':'||'0d'x|| 'Visa-Free Score = '||trim(left(visa_free_score)))|| ' target="visawin"'|| ' href='||quote('https://www.passportindex.org/comparebyPassport.php?p1='||trim(left(lowcase(isoalpha2)))); run; goptions device=png; goptions xpixels=1150 ypixels=600; goptions border; ODS LISTING CLOSE; ODS html path=odsout body="&name..htm" (title="Passport Visa-Free Score") style=htmlblue; goptions gunit=pct ftitle='albany amt/bold' ftext='albany amt' htitle=28pt htext=12pt; goptions ctext=gray33; legend1 position=(bottom left inside) /*mode=share*/ order=descending value=(j=c) label=(font='albany amt/bold' position=top 'Visa-Free Score') across=1 shape=bar(.15in,.15in) cframe=white cborder=graybb offset=(6,10); pattern1 v=s c=cxd7191c; pattern2 v=s c=cxfdae61; pattern3 v=s c=cxffffbf; pattern4 v=s c=cxa6d96a; pattern5 v=s c=cx1a9641; title1 ls=2.0 "How Powerful is Your Country's Passport?"; title2 h=1 ' '; proc gmap data=my_data map=my_map all; note link='https://www.passportindex.org/byRank.php' move=(2.0,1.5) h=11pt c=gray "Data source: passportindex.org (Oct 2017)"; note move=(42,1.5) h=11pt c=gray "Score shows how many countries your passport can visit visa-free (or by gaining a visa on arrival)"; id country; choro visa_free_score / levels=5 coutline=graycc cdefault=white legend=legend1 html=my_html des='' name="&name"; run; /* proc sql noprint; create table bad1 as select unique country from my_data where country not in (select unique country from my_map); create table bad2 as select unique country from my_map where country not in (select unique country from my_data); quit; run; title "Names in data with no match"; proc print data=bad1; run; title "Names in map with no match"; proc print data=bad2; run; */ proc sort data=my_data out=my_data; by descending visa_free_score country; run; data my_data; set my_data; length link $300 href $300; label link='Event'; href='href='|| quote('https://www.passportindex.org/comparebyPassport.php?p1='||trim(left(lowcase(isoalpha2)))); link = '' || htmlencode(trim(country)) || ''; run; title height=16pt "How Powerful is Your Country's Passport?"; proc print data=my_data label noobs style(data)={font_size=12pt} style(header)={font_size=12pt}; label visa_free_score='Visa-Free Score'; label link='Country'; var visa_free_score link; run; quit; ODS HTML CLOSE; ODS LISTING;