%let name=moving_average; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; data my_data; format date weekdate30.; format cases comma10.0; input date date9. cases; datalines; 01MAR2020 51 02MAR2020 29 03MAR2020 37 04MAR2020 66 05MAR2020 220 06MAR2020 188 07MAR2020 129 08MAR2020 241 09MAR2020 136 10MAR2020 281 11MAR2020 451 12MAR2020 500 13MAR2020 600 14MAR2020 910 15MAR2020 1210 16MAR2020 1477 17MAR2020 1985 18MAR2020 2200 19MAR2020 2400 20MAR2020 2528 21MAR2020 2665 22MAR2020 2860 23MAR2020 3183 24MAR2020 3930 25MAR2020 4337 26MAR2020 5615 27MAR2020 5933 28MAR2020 6024 29MAR2020 6100 30MAR2020 6200 31MAR2020 5923 01APR2020 6064 02APR2020 6022 03APR2020 6000 04APR2020 5533 05APR2020 5031 06APR2020 4851 07APR2020 4489 08APR2020 4633 09APR2020 4585 10APR2020 3990 11APR2020 3537 12APR2020 2946 13APR2020 2518 14APR2020 2487 15APR2020 2500 16APR2020 2445 17APR2020 2299 18APR2020 1945 19APR2020 1842 20APR2020 1881 21APR2020 1826 22APR2020 1757 23APR2020 1700 24APR2020 1670 25APR2020 1514 26APR2020 1257 27APR2020 1200 28APR2020 1154 29APR2020 1027 30APR2020 970 01MAY2020 868 02MAY2020 600 03MAY2020 550 ; run; proc expand data=my_data out=my_data; label cases_left_smoothed='7-day moving average (left)'; label cases_center_smoothed='7-day moving average (centered)'; convert cases=cases_left_smoothed / method=none transformout=(movave 7 trimleft 6); convert cases=cases_center_smoothed / method=none transformout=(cmovave 7 trim 3); run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Moving Average") style=htmlblue; ods graphics / imagemap tipmax=2500 imagefmt=png imagename="&name" noborder; title1 c=gray77 h=17pt "Cases of [disease name] per day"; proc sgplot data=my_data noborder; needle y=cases x=date / lineattrs=(color=orange thickness=2px) markers markerattrs=(color=gray77 symbol=circle); yaxis display=(nolabel noline noticks) grid gridattrs=(pattern=dot color=gray88) valueattrs=(color=gray33 size=10pt); xaxis display=(nolabel) type=time valueattrs=(color=gray33 size=10pt); run; proc sgplot data=my_data noborder; needle y=cases x=date / lineattrs=(color=orange thickness=2px) markers markerattrs=(color=gray77 symbol=circle); series y=cases_left_smoothed x=date / lineattrs=(color=red); yaxis display=(nolabel noline noticks) grid gridattrs=(pattern=dot color=gray88) valueattrs=(color=gray33 size=10pt); xaxis display=(nolabel) type=time valueattrs=(color=gray33 size=10pt); run; proc sgplot data=my_data noborder; needle y=cases x=date / lineattrs=(color=orange thickness=2px) markers markerattrs=(color=gray77 symbol=circle); series y=cases_center_smoothed x=date / lineattrs=(color=blue); yaxis display=(nolabel noline noticks) grid gridattrs=(pattern=dot color=gray88) valueattrs=(color=gray33 size=10pt); xaxis display=(nolabel) type=time valueattrs=(color=gray33 size=10pt); run; quit; ODS HTML CLOSE; ODS LISTING;