I have a 2 part question.
First - The output for the heatmap.
I am working with this code to create my output:
proc sgplot data=term_plot noautolegend;
title 'Term Attrition';
heatmapparm x=week_starting y=channel_subchannel
colorresponse=churn / colormodel=(green yellow red) outline ;
text x=week_starting y=channel_subchannel text=churn / textattrs=(size=11pt);
yaxis label="Channel";
xaxis label="Week Beginning";
run;
However, the output looks like this:
How can I get the cells to spread out? If I switch the x and y axis data, it looks fine:
But I want the dates to be on the bottom (x axis) so it's easier to read. Both x and y axis data is in text format.
Second part - Email data
When I try to send the email, it shows up fine on my own machine. However, on someone else's, the picture doesn't show up:
This is the code I use for the email:
%macro email;
data _null_;
call symputx("today",put(today(),mmddyy10.));
run;
options EMAILSYS=SMTP EMAILID="keegan.xxxx@yyyy.com" EMAILHOST="GESVR5050.yyyy.yyyyy.com";
FILENAME output EMAIL SUBJECT="Churn by Week as of &today."
FROM="keegan.xxxx@yyyyy.com"
TO=("keegan.xxxx@yyyyy.com")
BC=("keegan.xxxx@yyyy.com")
type='text/html'
CT ='text/html';
ods html3 body=OUTPUT
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 counts 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";
proc sgplot data=term_plot noautolegend;
title 'Term Attrition';
heatmapparm x=week_starting y=channel_subchannel
colorresponse=churn / colormodel=(green yellow red) outline ;
text x=week_starting y=channel_subchannel text=churn / textattrs=(size=11pt);
yaxis label="Channel";
xaxis label="Week Beginning";
run;
ods html3 close;
%mend;
%email;
Why doesn't the picture show up on someone else's machine? I want the output embedded in the email.
I appreciate your help!
Thanks!
Keegan
Make XAXIS wider ?
data WORK.OUT; infile datalines dsd truncover delimiter=' '; input Channel_SubChannel:$46. churn:PERCENT10.1 week_starting1:$9.; format churn PERCENT10.1; datalines; Broker-CallCenter 7.6% 06JUL2021 Broker-Web 12.0% 06JUL2021 CallCenter-CallCenter 4.7% 06JUL2021 PTC-CallCenter 15.5% 06JUL2021 PTC-Web 33.1% 06JUL2021 Web-Web 7.9% 06JUL2021 Broker-CallCenter 10.1% 13JUL2021 Broker-Web 9.3% 13JUL2021 CallCenter-CallCenter 4.7% 13JUL2021 PTC-CallCenter 12.3% 13JUL2021 PTC-Web 22.9% 13JUL2021 Web-Web 9.0% 13JUL2021 Broker-CallCenter 7.6% 20JUL2021 Broker-Web 9.0% 20JUL2021 CallCenter-CallCenter 5.9% 20JUL2021 PTC-CallCenter 10.0% 20JUL2021 PTC-Web 18.9% 20JUL2021 Web-Web 10.0% 20JUL2021 Broker-CallCenter 7.0% 27JUL2021 Broker-Web 12.7% 27JUL2021 CallCenter-CallCenter 6.2% 27JUL2021 PTC-CallCenter 12.1% 27JUL2021 PTC-Web 18.6% 27JUL2021 Web-Web 9.4% 27JUL2021 ; ods graphics/width=1000px height=500px ; proc sgplot data=OUT noautolegend; title 'Term Attrition'; heatmapparm y=channel_subchannel x=week_starting1 colorresponse=churn / colormodel=(green yellow red) outline; text y=channel_subchannel x=week_starting1 text=churn / textattrs=(size=11pt); yaxis label="Channel"; xaxis label="Week Beginning"; run;
Without data can't test anything but what I might start with:
Make sure your X axis is discrete and then use the DISCRETEX option in the Heatmapparm statement. You may also need to make your graphic are a bit wider with the ODS Graphics options.
First thing I would try is the HTML5 as Html3 does not embed images in the file. Open the html generated in your file I you likely have a reference pointing to a named PNG file that you did not include in the email. You would need to include the image files as well. Or possibly generate a PDF, RTF or DOCX file and mail that.
Hi Ballard!
Thank you for responding! Would you please be able to provide the syntax? It's not working right for me.
Also, I've attached the data so you can test it.
I appreciate your help!
Keegan
"Not working for me" is awful vague. Which isn't, the HTML5 or changes to the SGPLOT?
Are there errors in the log?: Post the code and log in a code box opened with the "<>" to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.
Many users here (I'm one) don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
Hi, I apologize for the vagueness.
When I change to HTML5, the logic runs correctly, but the output I get in the email looks like this:
I have followed your instructions to create a data step for you:
data WORK.OUT; infile datalines dsd truncover; input Channel_SubChannel:$46. churn:PERCENT10.1 week_starting1:$9.; format churn PERCENT10.1; datalines; Broker-Call Center 7.6% 06JUL2021 Broker-Web 12.0% 06JUL2021 Call Center-Call Center 4.7% 06JUL2021 PTC-Call Center 15.5% 06JUL2021 PTC-Web 33.1% 06JUL2021 Web-Web 7.9% 06JUL2021 Broker-Call Center 10.1% 13JUL2021 Broker-Web 9.3% 13JUL2021 Call Center-Call Center 4.7% 13JUL2021 PTC-Call Center 12.3% 13JUL2021 PTC-Web 22.9% 13JUL2021 Web-Web 9.0% 13JUL2021 Broker-Call Center 7.6% 20JUL2021 Broker-Web 9.0% 20JUL2021 Call Center-Call Center 5.9% 20JUL2021 PTC-Call Center 10.0% 20JUL2021 PTC-Web 18.9% 20JUL2021 Web-Web 10.0% 20JUL2021 Broker-Call Center 7.0% 27JUL2021 Broker-Web 12.7% 27JUL2021 Call Center-Call Center 6.2% 27JUL2021 PTC-Call Center 12.1% 27JUL2021 PTC-Web 18.6% 27JUL2021 Web-Web 9.4% 27JUL2021
Email code:
%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 body=OUTPUT 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 counts 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"; proc sgplot data=term_plot noautolegend; title 'Term Attrition'; heatmapparm y=channel_subchannel x=week_starting1 colorresponse=churn / colormodel=(green yellow red) outline; text y=channel_subchannel x=week_starting1 text=churn / textattrs=(size=11pt); yaxis label="Channel"; xaxis label="Week Beginning"; run; ods html5 close; %mend; %email;
Make XAXIS wider ?
data WORK.OUT; infile datalines dsd truncover delimiter=' '; input Channel_SubChannel:$46. churn:PERCENT10.1 week_starting1:$9.; format churn PERCENT10.1; datalines; Broker-CallCenter 7.6% 06JUL2021 Broker-Web 12.0% 06JUL2021 CallCenter-CallCenter 4.7% 06JUL2021 PTC-CallCenter 15.5% 06JUL2021 PTC-Web 33.1% 06JUL2021 Web-Web 7.9% 06JUL2021 Broker-CallCenter 10.1% 13JUL2021 Broker-Web 9.3% 13JUL2021 CallCenter-CallCenter 4.7% 13JUL2021 PTC-CallCenter 12.3% 13JUL2021 PTC-Web 22.9% 13JUL2021 Web-Web 9.0% 13JUL2021 Broker-CallCenter 7.6% 20JUL2021 Broker-Web 9.0% 20JUL2021 CallCenter-CallCenter 5.9% 20JUL2021 PTC-CallCenter 10.0% 20JUL2021 PTC-Web 18.9% 20JUL2021 Web-Web 10.0% 20JUL2021 Broker-CallCenter 7.0% 27JUL2021 Broker-Web 12.7% 27JUL2021 CallCenter-CallCenter 6.2% 27JUL2021 PTC-CallCenter 12.1% 27JUL2021 PTC-Web 18.6% 27JUL2021 Web-Web 9.4% 27JUL2021 ; ods graphics/width=1000px height=500px ; proc sgplot data=OUT noautolegend; title 'Term Attrition'; heatmapparm y=channel_subchannel x=week_starting1 colorresponse=churn / colormodel=(green yellow red) outline; text y=channel_subchannel x=week_starting1 text=churn / textattrs=(size=11pt); yaxis label="Channel"; xaxis label="Week Beginning"; run;
Thank you Sharp! That works for the output!
Do you have suggestions about emailing this output embedded in the email itself?
We solved the email question and embedded graph in another thread, using the techniques in How to send email using SAS .
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.