DATA Step, Macro, Functions and more

ODS: Writing email body and HTML attachment

Reply
New Contributor
Posts: 2

ODS: Writing email body and HTML attachment

Hello,

I'm attempting to create an email report which includes the results in the email body, and as a HTML attachment. At the moment I'm using a pair of ODS HTML statements and a 'filename email' statement. The code works, but I'm running it through Enterprise Guide 4.1, and it never actually ends until I force it to. The log reports no errors, and if I add anything extra after the email is sent that'll also run fine; Enterprise Guide just doesn't seem to realise that it's reached the end. If I replace the HTML attachment with any other kind the issue goes away, but I'd prefer to keep the attachment as HTML.

Here's a cut-down version of the code, which should demonstrate the problem:

/* Just make a sample table */

PROC SQL;

  CREATE TABLE extfile AS

  SELECT * FROM SASHELP.VEXTFL;

QUIT;

ods html(id=rpout) body="report.html";

filename doemail email to=("example@place.com")

  type='TEXT/HTML'

  subject="Test"

  from= "example@place.com"

  attach= ("report.html");

ods html body=doemail ENCODING='utf-8';

PROC PRINT DATA=WORK.extfile;

  VAR fileref xpath xengine;

RUN;

ods html(id=rpout) close;

ods html close;

Does anyone have any idea what might be causing this?

SAS Super FREQ
Posts: 8,744

Re: ODS: Writing email body and HTML attachment

Hi:

  I suspect there may be some timing issues. Generally, I do this for an email and attach example (NOT email in the body of the document).

1) create REPORT file in a separate step

2) issue FILENAME statement

3) use DATA step to send a brief message to initiate the email. This step is NOT inside an ODS "sandwich"

  See the example on page 7 of this paper: http://support.sas.com/resources/papers/proceedings11/300-2011.pdf

  Since you are trying to put the SAME report as an attachment and in the body of the email, you may be confusing ODS. EG just adds a layer of complexity, because EG will  be trying to make report output for you too. If you don't get this resolved yourself, then you might want to work with Tech Support on this question.

cynthia

New Contributor
Posts: 2

Re: ODS: Writing email body and HTML attachment

Thanks, Cynthia. I've just spotted this discussion, which looks like a very similar problem. However, the solutions listed there did not work in my case (and my problem does not trigger unless I have both HTML destinations open at once). Seems like it's probably an EG problem.

I was able to get around the problem by writing my report inside an ODS Document 'sandwich', and then using PROC DOCUMENT to replay it separately for each destination.

Ask a Question
Discussion stats
  • 2 replies
  • 657 views
  • 0 likes
  • 2 in conversation