%let name=power_bill; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* In this example, I use sas software to create a graph very similar to the one that Progress Energy used in their phone bills. */ %let targetyear=2003; %let targetmonth=9; data all_data; format kwh comma5.0; input year month kwh; n+1; format date date9.; date=input('01/'||trim(left(put(month,z2.)))||'/'||trim(left(year)),ddmmyy10.); datalines; 2002 9 800 2002 10 550 2002 11 200 2002 12 190 2003 1 250 2003 2 200 2003 3 225 2003 4 190 2003 5 325 2003 6 350 2003 7 675 2003 8 775 2003 9 875 ; run; /* determine the 'n' (obs number) of the desired billing month */ proc sql noprint; select n into :target_n from all_data where (year eq &targetyear) and (month eq &targetmonth); quit; run; /* subset to include just the desired billing month, and the 12 prior months */ proc sql noprint; create table my_data as select * from all_data where n between (&target_n - 12) and (&target_n); quit; run; data my_data; set my_data; if year eq &targetyear and month eq &targetmonth then billmonth=1; else billmonth=0; /* length myhtml $200; myhtml= 'title='||quote( 'Year: '||year||'0D'x|| 'Month: '||month||'0D'x|| 'kWh Usage'||put(kwh,comma5.0))|| ' href="power_info.htm"'; */ run; data anno_logo; length function $10 anchor $20 drawspace $20; function='image'; drawspace='graphpercent'; anchor='bottomleft'; x1=2; y1=91; widthunit='percent'; width=31.5; heightunit='percent'; height=7; layer='front'; image='../democd12/prog_ener.gif'; run; data anno_address; length label $100 x1space y1space $50; layer="front"; function="text"; textcolor="gray33"; textsize=12; width=100; widthunit='percent'; x1space='graphpercent'; y1space='graphpercent'; anchor='left'; x1=2; y1=86.5; label="JOHN DOE"; output; y1=y1-5; label="123 SOME DRIVE"; output; y1=y1-5; label="CARY, NC 27513-3322"; output; run; data anno_all; set anno_logo anno_address; run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Sample Power Bill Graph") 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=500px height=400px border; title1 h=13pt "kWh Usage History"; proc sgplot data=my_data noborder noautolegend pad=(top=26pct) sganno=anno_all; format date monyy7.; styleattrs datacolors=(cxcad5e4 gray55); vbarparm category=date response=kwh / group=billmonth outlineattrs=(color=gray77) tip=(date kwh); yaxis display=(nolabel noline noticks) thresholdmax=1 valueattrs=(weight=bold size=13pt) grid gridattrs=(color=graydd); xaxis display=(nolabel noticks) type=time fitpolicy=rotate valuesrotate=vertical; run; /* Below are the intermediate graphs I used in my blog */ /* title; proc print data=my_data noobs style(data)={font_size=11pt} style(header)={font_size=11pt}; format date date9.; var date kwh billmonth; run; title1 h=13pt "kWh Usage History"; title2 h=10pt "format date monyy7.;"; proc sgplot data=my_data noborder noautolegend; format date monyy7.; styleattrs datacolors=(cxcad5e4 gray55); vbarparm category=date response=kwh / group=billmonth outlineattrs=(color=gray77) tip=(date kwh); yaxis display=(nolabel noline noticks) thresholdmax=1 valueattrs=(weight=bold size=13pt) grid gridattrs=(color=graydd); xaxis display=(nolabel noticks) fitpolicy=rotate valuesrotate=vertical; run; title1 h=13pt "kWh Usage History"; title2 h=10pt "format date monname3.;"; proc sgplot data=my_data noborder noautolegend; format date monname3.; styleattrs datacolors=(cxcad5e4 gray55); vbarparm category=date response=kwh / group=billmonth outlineattrs=(color=gray77) tip=(date kwh); yaxis display=(nolabel noline noticks) thresholdmax=1 valueattrs=(weight=bold size=13pt) grid gridattrs=(color=graydd); xaxis display=(nolabel noticks); run; title1 h=13pt "kWh Usage History"; title2 h=10pt "xaxis type=time"; proc sgplot data=my_data noborder noautolegend; format date monname3.; styleattrs datacolors=(cxcad5e4 gray55); vbarparm category=date response=kwh / group=billmonth outlineattrs=(color=gray77) tip=(date kwh); yaxis display=(nolabel noline noticks) thresholdmax=1 valueattrs=(weight=bold size=13pt) grid gridattrs=(color=graydd); xaxis display=(nolabel noticks) type=time; run; title1 h=13pt "kWh Usage History"; title2 h=10pt "pad=(top=26pct)"; proc sgplot data=my_data noborder noautolegend pad=(top=26pct); format date monname3.; styleattrs datacolors=(cxcad5e4 gray55); vbarparm category=date response=kwh / group=billmonth outlineattrs=(color=gray77) tip=(date kwh); yaxis display=(nolabel noline noticks) thresholdmax=1 valueattrs=(weight=bold size=13pt) grid gridattrs=(color=graydd); xaxis display=(nolabel noticks) type=time; run; */ quit; ODS HTML CLOSE; ODS LISTING;