%let name=hours_per_vehicle; filename odsout '.'; /* SAS/Graph imitation of p. 141 from ... http://www.treasury.gov/initiatives/eesa/agreements/auto-reports/ChryslerRestructuringPlan.pdf */ data mydata; format hours comma5.0; input automaker $ 1-30 year hours; /* I want the axis to show 0 decimal places, and the pointlabels to show 2 decimal places, therefore I'm creating 2 variables. */ length hours_2 $5; hours_2 = trim(left(put(hours,comma5.2))); datalines; Chrysler 1996 40.53 Chrysler 1997 48.00 Chrysler 1998 46.00 Chrysler 1999 44.30 Chrysler 2000 44.30 Chrysler 2001 44.28 Chrysler 2002 40.60 Chrysler 2003 37.42 Chrysler 2004 35.85 Chrysler 2005 33.71 Chrysler 2006 32.90 Chrysler 2007 30.37 GM 1996 44.59 GM 1997 48.25 GM 1998 48.00 GM 1999 44.00 GM 2000 40.50 GM 2001 39.50 GM 2002 37.00 GM 2003 35.50 GM 2004 34.50 GM 2005 33.40 GM 2006 32.50 GM 2007 32.29 Ford 1996 37.59 Ford 1997 37.00 Ford 1998 37.20 Ford 1999 37.3 Ford 2000 40.00 Ford 2001 41.00 Ford 2002 40.00 Ford 2003 39.00 Ford 2004 37.50 Ford 2005 36.20 Ford 2006 35.40 Ford 2007 33.88 Honda 1996 30.88 Honda 1997 32.80 Honda 1998 30.80 Honda 1999 29.50 Honda 2000 29.08 Honda 2001 30.80 Honda 2002 34.95 Honda 2003 32.50 Honda 2004 32.58 Honda 2005 32.80 Honda 2006 31.80 Honda 2007 31.34 Toyota 1996 29.54 Toyota 1997 31.70 Toyota 1998 30.10 Toyota 1999 30.90 Toyota 2000 31.00 Toyota 2001 31.10 Toyota 2002 30.80 Toyota 2003 30.00 Toyota 2004 28.50 Toyota 2005 29.66 Toyota 2006 30.00 Toyota 2007 30.37 ; run; data mydata; set mydata; format pct_improvement percentn7.1; pct_improvement = -1*(hours-lag(hours))/lag(hours); run; data mydata; set mydata; length myhtml $300; myhtml= 'href="http://www.google.com/search?&q=hours+per+vehicle+productivity+'||trim(left(automaker))|| '" title='|| quote( trim(left(automaker))||' '||trim(left(year))||': '||trim(left(put(hours,comma5.2)))||' hpv' ||'0d'x|| 'Percent improvement over previous year = '||put(pct_improvement,percentn7.1) ); run; /* Downloaded Chrysler & Fiat logos from here: http://www.underconsideration.com/brandnew/archives/chrysler_detail.gif http://www.iue.it/Personal/Researchers/ae86_project1/image/ford_logo-small.gif http://www.nhli.org/corp_logos/gm_logo.gif http://www.rockbottomrestaurantsinc.com/RBFoundation/SponsorLogos/hondaLogo.gif http://www.fishingmonthly.com.au/tournaments/tournament-pg1/toyota_logo.gif Converted them to transparent-background gif here: http://stuff.mit.edu/tweb/map.html */ proc sql; create table anno_logo as select unique automaker, hours from mydata where year=1996; quit; run; data anno_logo; set anno_logo; length function $8 style $20 text $50; style='fit'; xsys='1'; ysys='2'; if automaker eq 'Chrysler' then do; function='move'; x=1.3; y=hours-1.2; output; function='image'; x=x+4.6; y=y+2.5; imgpath='./chrysler_logo.gif'; output; end; else if automaker eq 'GM' then do; function='move'; x=1.5; y=hours-1.2; output; function='image'; x=x+4.2; y=y+2.5; imgpath='./gm_logo.gif'; output; end; else if automaker eq 'Ford' then do; function='move'; x=0.5; y=hours-1.8; output; function='image'; x=x+6.1; y=y+3.8; imgpath='./ford_logo.gif'; output; end; else if automaker eq 'Toyota' then do; function='move'; x=1.5; y=hours-1.4; output; function='image'; x=x+4.2; y=y+1.5; imgpath='./toyota_logo.gif'; output; end; else if automaker eq 'Honda' then do; function='move'; x=1.5; y=hours-0.7; output; function='image'; x=x+4.2; y=y+1.7; imgpath='./honda_logo.gif'; output; end; run; proc sql; create table anno_pcts as select unique automaker, year, hours, pct_improvement from mydata where automaker='Chrysler' and year>=2002; quit; run; data anno_pcts; set anno_pcts; length function $8 style $20 text $50; xsys='2'; ysys='2'; function='move'; x=year; y=hours; output; xsys='7'; ysys='7'; function='draw'; line=33; color='gray55'; x=2; y=15; output; function='bar'; line=0; color='graybb'; style='solid'; x=4; y=4; output; function='move'; x=-1.9; y=-1.8; output; function='cntl2txt'; x=0; y=0; output; function='label'; position='5'; hsys='3'; size=2; color='black'; style=''; text=trim(left(put(pct_improvement,percentn7.1))); output; xsys='2'; ysys='2'; size=1; line=3; color='gray55'; hsys=''; function='move'; x=2002+.6; y=40.60+6; output; function='draw'; x=2007+.6; y=30.37+6; output; function='label'; x=2002+(2007-2002)/2+.6+.08; y=30.37+(40.60-30.37)/2+6+.8; text="Chrysler's % improvement"; color='gray99'; angle=-30; hsys='3'; size=2.7; output; run; data anno_all; set anno_logo anno_pcts; run; proc sql; create table foo as select unique year, hours as chrysler_hours from mydata where year eq 2007 and automaker='Chrysler'; create table anno_table as select unique automaker, year, hours from mydata where year eq 2007; create table anno_table as select unique anno_table.*, foo.chrysler_hours from anno_table left join foo on anno_table.year = foo.year; quit; run; proc sort data=anno_table out=anno_table; by hours; run; data anno_table; set anno_table; length function $8 text $50; linenum=_n_; var_to_chrysler=hours-chrysler_hours; xsys='3'; ysys='3'; hsys='3'; when='a'; function='label'; position='6'; x=73; y=93 - (linenum*3.5); text=trim(left(automaker)); output; position='5'; x=84; y=93 - (linenum*3.5); text=trim(left(hours)); output; x=93; y=93 - (linenum*3.5); text=trim(left(var_to_chrysler)); if automaker='Chrysler' then text='-----'; if (hours-chrysler_hours) > 0 then text='+'||trim(left(text)); output; run; data table_stuff; length function $8 text $50 color $8; xsys='3'; ysys='3'; hsys='3'; when='a'; function='label'; position='6'; x=72; y=97; text='2007 HARBOUR RESULTS'; output; position='5'; color='white'; x=93; y=93.5; text='Var. to Chrysler'; output; x=84; y=93.5; text='HPV'; output; when='b'; color=''; x=71; y=73; function='move'; output; x=x+28; y=y+14; function='bar'; style='solid'; line=0; color="cxf1eeea"; output; x=71; y=87; function='move'; output; x=x+28; y=y+4; function='bar'; style='solid'; line=0; color="cxd7dee9"; output; x=71; y=91; function='move'; output; x=x+28; y=y+4; function='bar'; style='solid'; line=0; color="cx133533"; output; x=71; y=73; function='move'; output; x=x+28; y=y+22; function='bar'; style='empty'; line=0; color="black"; output; run; data anno_table; set table_stuff anno_table; run; GOPTIONS DEVICE=png; goptions xpixels=900 ypixels=500; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm"; goptions ftitle="arial/bold" ftext="arial/bold" gunit=pct htitle=3.5 htext=2.7; goptions ctext=gray33; goptions cback=white; title1 j=l ls=1.5 " Hours Per Vehicle"; title2 j=l " (Assembly, Stamping, Engine & Transmission)"; axis1 label=none order=(25 to 50 by 5) minor=none offset=(0,0); axis2 label=none order=(1996 to 2008 by 1) major=none minor=(number=1) offset=(7,0) value=(t=13 ' '); symbol1 value=circle h=2 interpol=line width=2 color=red pointlabel=("#hours_2" j=r c=gray33); symbol2 value=circle h=2 interpol=line width=1 color=green; symbol3 value=circle h=2 interpol=line width=1 color=gray; symbol4 value=circle h=2 interpol=line width=1 color=orange; symbol5 value=circle h=2 interpol=line width=1 color=blue; proc gplot data=mydata anno=anno_all; plot hours*year=automaker / vaxis=axis1 haxis=axis2 /* autovref cvref=graydd */ nolegend noframe anno=anno_table html=myhtml des="" name="&name"; run; /* proc print data=anno_pcts; run; proc print data=anno_table; run; */ quit; ODS HTML CLOSE; ODS LISTING;