Reputation: 65
I've created a report in SAS EG 7.2 and have got SAS to email it in the body of the email, however I can't seem to add any text. I have got this code:
filename mymail email
to=('[email protected]')
subject='Report'
from='[email protected]'
Content_type="text/html";
ods _all_ close;
ODS ESCAPECHAR='^';
ods html body=mymail style=minimal;
proc report data=data…
…
run;
ods html close;
ods _all_ close;
This sends my email perfectly. And I can do this to add some text
filename mymail email
to=('[email protected]')
subject='Report'
from='[email protected]'
Content_type="text/html";
ods _all_ close;
ODS ESCAPECHAR='^';
ods html body=mymail style=minimal;
DATA _null_;
file mymail;
Put "Hello,"//
"You are recieving this mail because:"//;
if &warn1=1 then do;
put "&w1." //; end;
if &warn2=1 then do;
put "&w2." //; end;
put
"Regards,"//
"Chris";
run;
ods html close;
ods _all_ close;
But I can't seem to do both? If I include the text step and the proc report, I only see the report in the resulting email. Any ideas?
Thanks in advance :)
Upvotes: 1
Views: 3953
Reputation: 51611
Your solution of adding the text into the HTML file itself sounds best.
Your original code has a couple of issue.
First you have an access conflict. The DATA _NULL_
step is trying to write to the same file that the ODS HTML process is still writing to. Didn't you get an error message? or perhaps two separate emails?
Second even if you succeeded in writing text into the same file as the ODS HTML was producing it would be either before or after the <HTML>
..</HTML>
tags around the report generated by ODS HTML. As such it would probably be ignored by the recipient.
Upvotes: 1
Reputation: 65
If anyone is interested I managed to solve this by adding in the following line directly before the proc report:
ods html text="<div>Please find below the Reports </div> <br><br> There are &&totalwarnings. warnings for the last hour:<br><br>";
%if &warn1=1 %then %do;
ods html text="&&w1."; %end;
%if &warn2=1 %then %do;
ods html text="&&w2."; %end;
Upvotes: 1