%let name=vehicle_production; filename odsout '.'; /* https://en.wikipedia.org/wiki/List_of_countries_by_motor_vehicle_production http://www.oica.net/category/production-statistics/1999-statistics/ */ %let color1=cxa65628; %let color2=cx377eb8; %let color3=cx4daf4a; %let color4=cxff7f00; %let color5=cx984ea3; %let color6=cxe41a1c; %let color7=graycc; proc import datafile="vehicle_production.xls" dbms=XLS out=my_data REPLACE; range='Sheet1$A2:D1000'; getnames=YES; mixed=NO; run; data my_data; set my_data; if country in ('China' 'Japan' 'Germany' 'South Korea' 'India' 'USA') then plot_country=country; else plot_country='ZZ_'||trim(left(country)); run; proc sort data=my_data out=my_data; by descending plot_country year; run; data my_data; set my_data; by plot_country notsorted; length my_html $300; my_html= 'title='||quote( trim(left(country))||'0d'x|| trim(left(year))||'0d'x|| trim(left(put(cars,comma20.0))) ); output; if last.plot_country then do; year=.; output; end; run; data anno_country; set my_data (where=(year=2015 and country in ('China' 'Japan' 'Germany' 'South Korea' 'USA' 'India'))); xsys='2'; ysys='2'; hsys='3'; when='a'; function='label'; position='>'; x=year; y=cars; text='a0a0'x||trim(left(country)); /* adjust positions of overlapping labels */ if country='USA' then position='c'; if country='South Korea' then position='6'; if country='India' then position='6'; /* make the text color match the line color */ if country='China' then color="&color1"; if country='Germany' then color="&color2"; if country='India' then color="&color3"; if country='Japan' then color="&color4"; if country='South Korea' then color="&color5"; if country='USA' then color="&color6"; run; goptions device=png; goptions xpixels=900 ypixels=600; goptions noborder; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Cars manufactured per year, by country") style=htmlblue; goptions gunit=pct htitle=4 htext=2.5 ftitle="albany amt/bold" ftext="albany amt"; goptions ctext=gray33; symbol1 value=circle h=2.0 interpol=join color=&color1 repeat=1; /* China */ symbol2 value=circle h=2.0 interpol=join color=&color2 repeat=1; /* Germany */ symbol3 value=circle h=2.0 interpol=join color=&color3 repeat=1; /* India */ symbol4 value=circle h=2.0 interpol=join color=&color4 repeat=1; /* Japan */ symbol5 value=circle h=2.0 interpol=join color=&color5 repeat=1; /* South Korea */ symbol6 value=circle h=2.0 interpol=join color=&color6 repeat=1; /* USA */ symbol7 value=circle h=1.5 interpol=join color=&color7 ci=graye4 repeat=100; /* all others */ axis1 label=none style=0 order=(0 to 22000000 by 2000000) major=none minor=none; axis2 label=none minor=none value=( height=2.1 t=2 "'00" t=3 "'01" t=4 "'02" t=5 "'03" t=6 "'04" t=7 "'05" t=8 "'06" t=9 "'07" t=10 "'08" t=11 "'09" t=12 "'10" t=13 "'11" t=14 "'12" t=15 "'13" t=16 "'14" ); title1 ls=1.5 "Cars manufactured per year, by country"; title2 a=-90 h=10 ' '; footnote link='http://www.oica.net/category/production-statistics/2015-statistics/' font='albany amt' color=gray "Data source: International Organization of Motor Vehicle Manufacturers (OICA)"; proc gplot data=my_data anno=anno_country; format cars comma15.0; plot cars*year=plot_country / nolegend vaxis=axis1 haxis=axis2 noframe autovref cvref=gray33 lvref=33 html=my_html des='' name="&name"; run; data data_2015; set my_data (where=(year=2015 and country in ('China' 'Japan' 'Germany' 'South Korea' 'India' 'USA'))); length my_html $300; my_html='title='||quote( trim(left(country))||'0d'x|| trim(left(put(cars,comma20.0)))); run; pattern1 v=psolid c=&color1; pattern2 v=psolid c=&color2; pattern3 v=psolid c=&color3; pattern4 v=psolid c=&color4; pattern5 v=psolid c=&color5; pattern6 v=psolid c=&color6; ods html anchor='pie'; title1 ls=1.5 "Cars manufactured in 2015, by the top 6 countries"; proc gchart data=data_2015; format cars comma20.0; pie country / type=sum sumvar=cars descending noheading coutline=gray77 percent=outside value=none slice=outside html=my_html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;