The SAS Output Delivery System and reporting techniques

Sending emails from SAS with embedded table from dataset

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Sending emails from SAS with embedded table from dataset

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!

 


Accepted Solutions
Solution
‎09-25-2016 03:46 AM
New Contributor
Posts: 4

Re: Sending emails from SAS with embedded table from dataset

Posted in reply to DanielDor

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.

View solution in original post


All Replies
Solution
‎09-25-2016 03:46 AM
New Contributor
Posts: 4

Re: Sending emails from SAS with embedded table from dataset

Posted in reply to DanielDor

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.

Contributor
Posts: 23

Re: Sending emails from SAS with embedded table from dataset

Posted in reply to mstacey_foresters_com

Thanks! Work like a charm Smiley Happy

New Contributor
Posts: 2

Re: Sending emails from SAS with embedded table from dataset

[ Edited ]
Posted in reply to DanielDor

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?

New Contributor
Posts: 4

Re: Sending emails from SAS with embedded table from dataset

Hello, 

 

What do you mean by CRON job, is this a batch job?

New Contributor
Posts: 2

Re: Sending emails from SAS with embedded table from dataset

Posted in reply to mstacey_foresters_com

Yes, this is to schedule sas jobs. 

New Contributor
Posts: 4

Re: Sending emails from SAS with embedded table from dataset

Can you send me an email of the output produced through the batch?

mstacey@foresters.com

New Contributor
Posts: 4

Re: Sending emails from SAS with embedded table from dataset

I had the same problem.  If you don't already have it, try adding:

 

Options validvarname='any';

 

This enabled my Cron jobs to run successfully.

Occasional Learner
Posts: 1

Re: Sending emails from SAS with embedded table from dataset

Posted in reply to PrimeDougR

Hi,

 

thank you for this i have found it extremely useful and works like a charm.

 

i would like to know how i add a border between the columns and rows?

 

if you have any useful links or reading material for me to find the different styles it would be appreciated.

SAS Super FREQ
Posts: 9,366

Re: Sending emails from SAS with embedded table from dataset

Hi:
The original poster was using style=noline -- which implies a custom style was in place. They also had HEADLINE and HEADSKIP, which are ignored by ODS HTML.

But, instead of style=noline, you could try one of the predefined styles, like:
style=journal
style=sasweb
style=default
style=htmlblue
style=watercolor
style=pearl

And see which one you like best.

cynthia
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 4148 views
  • 3 likes
  • 6 in conversation