%let name=halloween_candy_ranking; filename odsout '.'; /* Based on Oct 19, 2015 (10:40am est) data from: http://www.ranker.com/crowdranked-list/best-halloween-candy?format=GRID&page=1&action=tab&type=list */ data my_data; input rank thumbs_up thumbs_down name $ 12-80; datalines; 1 926 216 Reese's Peanut Butter Cups 2 796 209 Twix 3 871 161 Kit Kat 4 691 217 Snickers 5 554 246 Hershey's Miniatures 6 577 272 Reese's Peanut Butter Pumpkins 7 525 268 Starburst 8 522 306 Butterfinger 9 540 262 Skittles 10 482 285 Gummy Bear 11 500 112 M&M's 12 518 283 Sour Patch Kids 13 388 295 Jolly Rancher 14 434 332 Smarties 15 393 284 Spooky Nerds 16 362 201 Nerds 17 386 330 Twizzlers 18 400 289 Milk Duds 19 308 285 Swedish Fish 20 418 179 Nestle Crunch 21 338 148 Reese's Pieces 22 335 334 Tootsie Rolls 23 379 206 Milky Way 24 365 266 Peppermint Patty 25 336 372 Candy Corn 26 305 118 Hershey's Kisses 27 315 85 Hershey bar 28 297 187 Charms Blow Pop 29 274 258 Baby Ruth 30 302 160 3 Musketeers 31 275 261 Sweet Tarts 32 319 262 Nestle Crunch Pumpkins 33 288 269 Almond Joy 34 279 211 Laffy Taffy 35 202 180 Mike and Ikes 36 182 132 Airheads Extreme 37 254 304 Milky Way Caramel Apple 38 244 119 Fun Dip 39 260 294 Cadbury Screme Eggs 40 207 176 Caramel Apple Pops 41 239 281 Mounds 42 226 258 Candy Corn M&Ms 43 192 255 Dots 44 151 343 Godiva Pumpkin Spice Caramels 45 131 174 Jelly bean 46 187 166 100 Grand Bar 47 146 348 Pumpkin Spice Hershey Kiss 48 134 125 Krackel 49 31 27 Mr. Goodbar 50 26 33 Heath bar 51 9 27 Boston Baked Beans 52 11 33 Bit-O-Honey 53 11 35 Salted Nut Roll 54 7 40 Nut Goodie ; run; proc transpose data=my_data out=tran_data; by rank name; run; data tran_data; set tran_data; if _name_='thumbs_down' then col1=col1*-1; length my_html $300; my_html= 'title='||quote('Rank #'||trim(left(rank))||': '||trim(left(name)))|| ' href='||quote('http://www.google.com/search?&q='||trim(left(name))||'+halloween candy'); run; data anno_names; set my_data; length function $8 text $100; hsys='d'; when='a'; function='label'; position='>'; size=10; color='gray22'; ysys='2'; midpoint=rank; xsys='2'; x=15; position='>'; text=trim(left(thumbs_up)); output; xsys='2'; x=-15; position='<'; text=trim(left(thumbs_down)); output; xsys='1'; x=1; position='>'; length html $300; html= 'title='||quote('Rank #'||trim(left(rank))||': '||trim(left(name)))|| ' href='||quote('http://www.google.com/search?&q='||trim(left(name))||'+halloween candy'); text=trim(left(name)); output; html=''; hsys='3'; function='txt2cntl'; output; function='draw'; size=.01; xsys='2'; x=0; ysys='7'; y=0; color='gray55'; line=33; when='b'; output; run; proc sql noprint; create table control as select unique rank as start, name as label from tran_data; quit; run; data control; set control; fmtname='barfmt'; type='N'; run; proc format lib=work cntlin=control; run; proc format; picture posval low-high='000,009'; run; proc sql noprint; create table control as select unique rank as start, name as label from tran_data; quit; run; data control; set control; fmtname='barfmt'; type='N'; run; proc format lib=work cntlin=control; run; proc format; picture posval low-high='000,009'; run; goptions device=png; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Halloween Candy Ranking") style=htmlblue; goptions gunit=pct htitle=30pt ftitle="albany amt/bold" htext=10pt ftext="albany amt"; goptions ctext=gray33; pattern1 v=s c=gray88; pattern2 v=s c=cxEE7600; axis1 label=none style=0 order=(-600 to 1000 by 200) major=none minor=none value=none offset=(22,0); axis2 label=none style=0 value=none; goptions xpixels=700 ypixels=1000; title1 move=(+5,+0) ls=1.5 "Halloween Candy Ranking"; title2 move=(+5,+0) "Number of votes against (thumbs down) and for (thumbs up) each candy"; title3 h=40pt ' '; title4 h=5pt a=90 ' '; title5 h=5pt a=-90 ' '; footnote1 link='http://www.ranker.com/crowdranked-list/best-halloween-candy?format=GRID&page=1&action=tab&type=list' ls=1.0 c=gray "Data source: ranker.com, Oct 19, 2015 snapshot"; proc gchart data=tran_data anno=anno_names; format rank barfmt.; format col1 posval.; note move=(37,83.5) h=10 c=gray55 font='Wingdings' '44'x; note move=(57,83.5) h=10 c=cxEE7600 font='Wingdings' '43'x; note move=(49.8,83.5) 'votes'; hbar rank / discrete type=sum sumvar=col1 nostats subgroup=_name_ nolegend raxis=axis1 maxis=axis2 noframe space=0 coutline=gray33 html=my_html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;