%let name=us_primary_mortgage_rate; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* Similar to graphs in this post by Leonard Kiefer: https://twitter.com/lenkiefer/status/1116679787190333440 Using data from: http://www.freddiemac.com/pmms/ historicalweeklydata.xls */ proc import datafile="historicalweeklydata.xls" dbms=xls out=historical_data; range='Full History$a8:b0'; getnames=no; run; proc import datafile="historicalweeklydata.xls" dbms=xls out=data_2019; range='1PMMS2019$a8:b22'; getnames=no; run; data my_data; set historical_data (rename=(a=date b=rate)) data_2019 (rename=(a=date b=rate)); year=.; year=year(date); day_of_year=.; day_of_year=put(date,julday.); year_color=.; year_color=mod(year,10); rate=rate/100; run; data myattrs; length value $100; id="some_id"; value=0; fillcolor="cx19ace5"; output; value=1; fillcolor="cx36b1ab"; output; value=2; fillcolor="cx61ad87"; output; value=3; fillcolor="cx7bb056"; output; value=4; fillcolor="cx989f3a"; output; value=5; fillcolor="cxb78a35"; output; value=6; fillcolor="cxdc7624"; output; value=7; fillcolor="cx9f7c61"; output; value=8; fillcolor="cx5a7585"; output; value=9; fillcolor="cx1777b9"; output; run; data myattrs; set myattrs; linecolor=fillcolor; run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="U.S. Primary Mortgage Rate") style=htmlblue; ods graphics / noscale /* if you don't use this option, the text will be resized */ imagemap tipmax=25000 imagefmt=png imagename="&name" width=1000px height=800px noborder; title1 c=gray33 h=14pt "U.S. Weekly 30-year Fixed Mortgage Rate"; footnote c=gray77 h=10pt "Data source: Freddie Mac Primary Mortgage Marker Survey (weekly data through April 11, 2019)"; ods graphics / width=1000px height=250px; ods html anchor='original'; proc sgpanel data=my_data (where=(year>=2010)) noautolegend dattrmap=myattrs; panelby year / layout=panel columns=10 rows=1 noheader novarname noborder; band x=day_of_year lower=0 upper=rate / group=year_color attrid=some_id transparency=.50 tip=none; series x=day_of_year y=rate / group=year_color attrid=some_id tip=(date rate) tipformat=(date9. percent7.1) tiplabel=('Week' 'Rate'); inset year / position=bottom nolabel textattrs=(color=gray33 size=10pt); rowaxis values=(.03 to .055 by .005) display=(nolabel noline noticks) valueattrs=(color=gray33 size=10pt) valuesformat=percent7.1 grid offsetmin=0 offsetmax=0; colaxis values=(0 to 366 by 366) valueattrs=(color=gray33 size=10pt) display=(nolabel noline noticks novalues) grid offsetmin=0 offsetmax=0; run; ods html anchor='line'; proc sgpanel data=my_data (where=(year>=2010)) noautolegend dattrmap=myattrs; panelby year / layout=panel columns=10 rows=1 noheader novarname noborder; series x=day_of_year y=rate / group=year_color attrid=some_id tip=(date rate) tipformat=(date9. percent7.1) tiplabel=('Week' 'Rate'); inset year / position=bottom nolabel textattrs=(color=gray33 size=10pt); rowaxis values=(.03 to .055 by .005) display=(nolabel noline noticks) valueattrs=(color=gray33 size=10pt) valuesformat=percent7.1 grid offsetmin=0 offsetmax=0; colaxis values=(0 to 366 by 366) valueattrs=(color=gray33 size=10pt) display=(nolabel noline noticks novalues) grid offsetmin=0 offsetmax=0; run; ods html anchor='zero'; proc sgpanel data=my_data (where=(year>=2010)) noautolegend dattrmap=myattrs; panelby year / layout=panel columns=10 rows=1 noheader novarname noborder; band x=day_of_year lower=0 upper=rate / group=year_color attrid=some_id transparency=.50 tip=none; series x=day_of_year y=rate / group=year_color attrid=some_id tip=(date rate) tipformat=(date9. percent7.1) tiplabel=('Week' 'Rate'); inset year / position=bottom nolabel textattrs=(color=gray33 size=10pt); rowaxis values=(0 to .06 by .01) display=(nolabel noline noticks) valueattrs=(color=gray33 size=10pt) valuesformat=percent7.0 grid offsetmin=0 offsetmax=0; colaxis values=(0 to 366 by 366) valueattrs=(color=gray33 size=10pt) display=(nolabel noline noticks novalues) grid offsetmin=0 offsetmax=0; run; ods graphics / width=1000px height=800px; ods html anchor='years'; proc sgpanel data=my_data (where=(year>=1980)) noautolegend dattrmap=myattrs; panelby year / layout=panel columns=10 rows=4 noheader novarname noborder; band x=day_of_year lower=0 upper=rate / group=year_color attrid=some_id transparency=.50 tip=none; series x=day_of_year y=rate / group=year_color attrid=some_id tip=(date rate) tipformat=(date9. percent7.1) tiplabel=('Week' 'Rate'); inset year / position=bottom nolabel textattrs=(color=gray33 size=10pt); rowaxis values=(0 to .20 by .05) display=(nolabel noline noticks) valuesdisplay=('0%' '5%' '10%' '15%' ' ') valueattrs=(color=gray33 size=10pt) valuesformat=percent7.0 grid offsetmin=0 offsetmax=0; colaxis values=(0 to 366 by 366) valueattrs=(color=gray33) display=(nolabel noline noticks novalues) grid offsetmin=0 offsetmax=0; run; /* proc print data=my_data; run; */ quit; ODS HTML CLOSE; ODS LISTING;