SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
JCatling
Calcite | Level 5

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?

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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

JCatling
Calcite | Level 5

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2716 views
  • 0 likes
  • 2 in conversation