12-05-2012 06:23 PM
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 */
CREATE TABLE extfile AS
SELECT * FROM SASHELP.VEXTFL;
ods html(id=rpout) body="report.html";
filename doemail email to=("email@example.com")
ods html body=doemail ENCODING='utf-8';
PROC PRINT DATA=WORK.extfile;
VAR fileref xpath xengine;
ods html(id=rpout) close;
ods html close;
Does anyone have any idea what might be causing this?
12-05-2012 10:18 PM
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.
12-06-2012 08:10 PM
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.