Greetings,
1. I would like to send email using SAS, and would like to include a table from SAS embedded inside the email itself (not with attached file).
2. What would be the best way to address this issue? Should I use ODS for this or some other process?
Thanks!
D
This will Produce a table inside the email.
options emailsys=smtp;
options emailauthprotocol=none;
options emailhost="xx.xx.xx";
options emailport=25;
options emailpw = "xxxxxx";
filename temp email
to = ( "xxxxx@xxxx.com" )
cc = ("xxxxx@xxxx.com" )
subject="Email With Table"
type="text/html"
from = "xxxxx@xxxx.com"
reply = "xxxxx@xxxx.com" ;
ODS html body=temp style = noline;
ods html text = "Good Morning,";
ods html text = "";
PROC REPORT DATA=X nowd HEADLINE HEADSKIP
style (report) = {background = white
font_face = "Verdana" font_size = 7pt just=left }
style (column) = {background = white CELLHEIGHT = 2.5%
font_face = "Verdana" font_size = 7pt just=left}
style (header) = {foreground = cx5e2750 font_face="Verdana"
font_size = 8pt just=left
background = white} ;
columns
DATE
TIME
FN
C;
DEFINE DATE / 'Date';
define TIME / 'Time';
define FN / "File Name";
define C / "Run Number";
run;
ods html text = "Have a Great Day.";
ods _all_ close;
Cheers.
This will Produce a table inside the email.
options emailsys=smtp;
options emailauthprotocol=none;
options emailhost="xx.xx.xx";
options emailport=25;
options emailpw = "xxxxxx";
filename temp email
to = ( "xxxxx@xxxx.com" )
cc = ("xxxxx@xxxx.com" )
subject="Email With Table"
type="text/html"
from = "xxxxx@xxxx.com"
reply = "xxxxx@xxxx.com" ;
ODS html body=temp style = noline;
ods html text = "Good Morning,";
ods html text = "";
PROC REPORT DATA=X nowd HEADLINE HEADSKIP
style (report) = {background = white
font_face = "Verdana" font_size = 7pt just=left }
style (column) = {background = white CELLHEIGHT = 2.5%
font_face = "Verdana" font_size = 7pt just=left}
style (header) = {foreground = cx5e2750 font_face="Verdana"
font_size = 8pt just=left
background = white} ;
columns
DATE
TIME
FN
C;
DEFINE DATE / 'Date';
define TIME / 'Time';
define FN / "File Name";
define C / "Run Number";
run;
ods html text = "Have a Great Day.";
ods _all_ close;
Cheers.
Thanks! Work like a charm 🙂
I am using the same code but for, "options emailhost = "XX.XX.XX" ; ". I am getting error. I am using my company's host email yet it says, "Email host couldn't be found"
what could be wrong, someone please help me
Thanks
Use following. Keep adding Proc Report for all additional dataset you want to send in email:-
filename temp email
TO=("email@domainname.com")
subject="POC starting Queue"
type="text/html"
from = "youremail@domainname.com";
ODS html body=temp style = analysis;
ods html text = "Hi All";
ods html text = " ";
ods html text = "Following Accounts are pending POC :-";
PROC Report data=RVPOCFINAL nowd HEADLINE HEADSKIP
style (report) = {background = white
font_face = "Verdana" font_size = 7pt just=left }
style (column) = {background = white CELLHEIGHT = 2.5%
font_face = "Verdana" font_size = 7pt just=left}
style (header) = {foreground = cx5e2750 font_face="Verdana"
font_size = 8pt just=left
background = white} ;
columns
column_name1
column_name2
column_namexx
;
run;
i have a different issue related to this. It works fine as long as I'm running the code manually. However When I'm running this through cron job, it is not capturing the columns. Anyone has any idea to solve for this?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.