Hi @ChrisHemedinger ,
I'm having an issue with extra text in an email I'm sending. Here is my output:
I've highlighted the text I'm trying to get rid of. I already have the titles in the charts themselves, and I'm also not sure why they are in the wrong positions, but I just want to remove them.
Here is the code I'm using:
%macro email;
data _null_;
call symputx("today",put(today(),mmddyy10.));
run;
options EMAILSYS=SMTP EMAILID="keegan.xxxxx@xxxxx.com" EMAILHOST="GESVR5050.xxxxx.xxxxx.com";
FILENAME output EMAIL SUBJECT="Churn by Week as of &today."
FROM="keegan.xxxxx@xxxxx.com"
TO=("keegan.xxxxx@xxxxx.com")
BC=("keegan.xxxxx@xxxxx.com")
type='text/html'
CT ='text/html';
ods html5 (id=mail) body=OUTPUT options(bitmap_mode="inline")
style=htmlblue;
ods escapechar='^';
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Good morning,";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}See churn below and let me know if you have questions.";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Thanks,";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Keegan";
ods graphics/ imagefmt=png width=1000px height=250px;
proc sgplot data=term_plot noautolegend;
title 'Term Attrition';
heatmapparm y=prod_group x=week_starting1
colorresponse=churn / colormodel=(green yellow red) outline;
text y=prod_group x=week_starting1 text=churn / textattrs=(size=11pt) ;
yaxis label="Product Group";
xaxis label="Week Beginning";
run;
proc sgrender data=attr_no_var
template=my_pie_chart;
run;
ods html5 (id=mail) close;
%mend;
%email;
I don't see why it's putting this text at the top. Do you have suggestions?
TITLE (and FOOTNOTE) are global statements that affect all of your procedure output until you "clear" them by entering an empty statement:
title; footnote;
So I'd advise adding these to the top of your program or at least before the ODS HTML5 statements. I see you placed a TITLE statement "inside" the PROC SGPLOT step, but since it's a global statement it's actually compiled and takes effect in the same way it would if you added it before the PROC. It's a style preference that many coders have though -- to place the global statements inside the procedure block they are intended to affect.
When you're "done" with that TITLE, clear it with an empty TITLE statement as shown above.
Try adding gtitle to the ODS HTML5 statement. That will put the title inside the graph image instead of in the text.
And if you don't want the title in the image, add an empty TITLE; statement before the procedure (like your SGRENDER).
Hey Chris!
This seems to remove the other title, but then just adds the 'Term Attrition' in it's place:
Here is the updated code:
ods html5 (id=mail) body=OUTPUT options(bitmap_mode="inline") gtitle
style=htmlblue;
ods escapechar='^';
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Good morning,";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}See churn below and let me know if you have questions.";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Thanks,";
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black}Keegan";
ods graphics/ imagefmt=png width=1000px height=250px;
proc sgplot data=term_plot noautolegend;
title 'Term Attrition';
heatmapparm y=prod_group x=week_starting1
colorresponse=churn / colormodel=(green yellow red) outline;
text y=prod_group x=week_starting1 text=churn / textattrs=(size=11pt) ;
yaxis label="Product Group";
xaxis label="Week Beginning";
run;
proc sgrender data=attr_no_var
template=my_pie_chart;
run;
ods html5 (id=mail) close;
%mend;
%email;
Also, I do want the titles within the image itself, just not outside of the image as stand alone text.
TITLE (and FOOTNOTE) are global statements that affect all of your procedure output until you "clear" them by entering an empty statement:
title; footnote;
So I'd advise adding these to the top of your program or at least before the ODS HTML5 statements. I see you placed a TITLE statement "inside" the PROC SGPLOT step, but since it's a global statement it's actually compiled and takes effect in the same way it would if you added it before the PROC. It's a style preference that many coders have though -- to place the global statements inside the procedure block they are intended to affect.
When you're "done" with that TITLE, clear it with an empty TITLE statement as shown above.
Thank you so much Chris! That worked!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.