%let name=victoria_versus_raleigh; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* Based on Brian Rupers's comments in my Canada blog https://blogs.sas.com/content/sastraining/2017/08/10/us-states-north-of-canada/ I decided to plot the temperature of Victoria vs Raleigh Using data from: https://en.climate-data.org/north-america/canada/british-columbia/victoria-631/ https://en.climate-data.org/north-america/united-states-of-america/north-carolina/raleigh-1714/ */ proc format; value mon_fmt 1='Jan' 2='Feb' 3='Mar' 4='Apr' 5='May' 6='Jun' 7='Jul' 8='Aug' 9='Sep' 10='Oct' 11='Nov' 12='Dec' ; run; data my_data; length city $50; input city mon_01 mon_02 mon_03 mon_04 mon_05 mon_06 mon_07 mon_08 mon_09 mon_10 mon_11 mon_12; infile datalines dlm='09'x; /* tab-delimited data */ datalines; Raleigh 39.6 42.4 50.5 59.5 67.6 74.8 78.4 77.2 71.2 59.9 51.3 42.8 Victoria 39.7 42.1 44.2 47.8 52.9 56.7 59.9 59.9 57.0 50.4 44.4 40.8 ; run; proc transpose data=my_data out=my_data; by city notsorted; run; data my_data; set my_data (rename=(_name_=mon col1=avg_temperature_f)); month=.; month=scan(mon,2,'_'); run; data anno_seasons; length function x1space y1space anchor $50; layer="front"; function="text"; textcolor="gray33"; textsize=9; textweight='bold'; anchor='center'; width=50; widthunit='percent'; x1space='datavalue'; y1space='datavalue'; length label $100; x1=2; y1=95; label='Winter'; output; x1=5; y1=95; label='Spring'; output; x1=8; y1=95; label='Summer'; output; x1=11; y1=95; label='Fall'; output; anchor='right'; x1space='wallpercent'; x1=0; y1=32; label='Freezing'; output; run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Temperature: Victoria vs Raleigh") 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=800px height=600px noborder; ods escapechar='^'; title1 c=gray33 h=18pt "Raleigh, North Carolina -vs- Victoria, Canada"; title2 c=gray33 h=15pt "Average Monthly Temperature"; footnote c=gray h=12pt "Data source: climate-data.org (January 2020 snapshot)"; proc sgplot data=my_data; styleattrs datacontrastcolors=(red cx1C86EE); series x=month y=avg_temperature_f / group=city smoothconnect lineattrs=(thickness=5); xaxis values=(1 to 12 by 1); run; /* */ proc sgplot data=my_data noautolegend sganno=anno_seasons noborder pad=(left=5pct); format month mon_fmt.; styleattrs datacontrastcolors=(red cx1C86EE); refline 3.4 6.4 9.4 / axis=x lineattrs=(color=graydd); refline 32 / axis=y lineattrs=(pattern=dot color=gray88) /* Can't have refline labels outside, when also using xaxistable.*/ /* label="Freezing" labelloc=outside labelpos=min */ ; series x=month y=avg_temperature_f / group=city smoothconnect lineattrs=(thickness=5) curvelabel curvelabelpos=end markers markerattrs=(color=graycc); yaxis display=(nolabel) values=(20 to 100 by 20) valuesdisplay=("20^{unicode '00ba'x}" "40^{unicode '00ba'x}" "60^{unicode '00ba'x}" "80^{unicode '00ba'x}" "100^{unicode '00ba'x}") valueattrs=(size=11pt weight=bold color=gray33) grid gridattrs=(color=graydd) offsetmin=0 offsetmax=0; xaxis display=(nolabel) values=(1 to 12 by 1) valueattrs=(size=11pt weight=bold color=gray33) offsetmin=.05 offsetmax=.07 ; xaxistable avg_temperature_f / x=month class=city colorgroup=city valueattrs=(weight=bold size=11pt color=gray weight=normal) labelattrs=(weight=bold size=11pt) labelpos=left; run; quit; ODS HTML CLOSE; ODS LISTING;