%let name=star_wars_releases; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* Graphing data from Star Wars wikipedia page: https://en.wikipedia.org/wiki/Star_Wars#Film */ data releases; input release_date date9. title_info $ 11-80; length episode $20; episode=trim(left(scan(trim(left(scan(title_info,2,':'))),1,'-'))); length episode_roman $5; episode_roman=scan(episode,2,' '); if episode_roman='I' then episode_num=1; if episode_roman='II' then episode_num=2; if episode_roman='III' then episode_num=3; if episode_roman='IV' then episode_num=4; if episode_roman='V' then episode_num=5; if episode_roman='VI' then episode_num=6; if episode_roman='VII' then episode_num=7; if episode_roman='VIII' then episode_num=8; if episode_roman='IX' then episode_num=9; length title $100; title=trim(left(scan(title_info,2,'-'))); datalines; 25May1977 Star Wars: Episode IV - A New Hope 21may1980 Star Wars: Episode V - The Empire Strikes Back 25may1983 Star Wars: Episode VI - Return of the Jedi 19may1999 Star Wars: Episode I - The Phantom Menace 16may2002 Star Wars: Episode II - Attack of the Clones 19may2005 Star Wars: Episode III - Revenge of the Sith 18dec2015 Star Wars: Episode VII - The Force Awakens 15dec2017 Star Wars: Episode VIII - The Last Jedi 20dec2019 Star Wars: Episode IX - The Rise of Skywalker ; run; proc sort data=releases out=releases; by descending release_date; run; data releases; set releases; end_date=lag(release_date); if end_date=. then end_date="01jan2030"d; if episode_num in (1 2 3) then group_of_3=2; if episode_num in (4 5 6) then group_of_3=1; if episode_num in (7 8 9) then group_of_3=3; length my_url $300; my_url='http://www.google.com/search?&q='||trim(left(title_info)); run; /* highlow only labels to the left or right of the bars, but I want to label on top, therefore I will use annotate... */ data anno_labels; set releases; length label $300 anchor x1space y1space function textcolor $50; layer='front'; x1space='datavalue'; y1space='datavalue'; function='text'; textcolor='gray55'; textsize=9.5; textweight='normal'; width=100; widthunit='percent'; label=trim(left(title)); x1=release_date; y1=episode_num+.4; anchor='left'; run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Star Wars Timeline") style=htmlblue; ods graphics / noscale /* if you don't use this option, the text will be resized */ imagemap tipmax=2500 imagefmt=png imagename="&name" width=900px height=600px noborder; title1 c=gray33 h=20pt "Star Wars Trilogy Movies Timeline"; /* ods graphics / width=800px height=600px; proc sgplot data=releases; format release_date year4.; scatter y=episode_num x=release_date / datalabel=title; yaxis values=(1 to 9) grid gridattrs=(pattern=dot color=gray88); xaxis grid gridattrs=(pattern=dot color=gray88); run; proc sgplot data=releases noautolegend; format end_date year4.; highlow y=episode_num low=release_date high=end_date / type=bar barwidth=.40 group=group_of_3 lowlabel=title; yaxis values=(1 to 9) grid gridattrs=(pattern=dot color=gray88); xaxis grid gridattrs=(pattern=dot color=gray88); run; */ proc sgplot data=releases noautolegend noborder sganno=anno_labels; format episode_num roman5.; format release_date end_date year4.; label episode_num='Episode'; label end_date='Release Date'; styleattrs datacolors=(cxfdc086 cx7fc97f cxbeaed4); highlow y=episode_num low=release_date high=end_date / type=bar barwidth=.40 group=group_of_3 lineattrs=(color=gray77) tip=(title_info release_date) tipformat=(auto date9.) url=my_url ; yaxis display=(noticks noline) labelattrs=(weight=bold size=11pt color=gray33) valueattrs=(size=10pt color=gray33) values=(1 to 9 by 1) offsetmin=.05 offsetmax=.09 grid gridattrs=(pattern=dot color=gray88) ; xaxis display=(noticks noline) labelattrs=(weight=bold size=11pt color=gray33) valueattrs=(size=10pt color=gray33) values=('01jan1975'd to '01jan2030'd by year5) offsetmin=0 offsetmax=0 grid gridattrs=(pattern=dot color=gray88) ; run; quit; ODS HTML CLOSE; ODS LISTING;