从SAS发送包含报告和文字的电子邮件

时间:2018-06-11 10:53:30

标签: sas enterprise-guide proc-report

我已经在SAS EG 7.2中创建了一份报告,并且已经让SAS通过电子邮件发送电子邮件,但我似乎无法添加任何文本。我有这个代码:

filename mymail email   
                    to=('mail@email.com')
                    subject='Report'
                    from='mail@email.com'
                    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;

这完美地发送了我的电子邮件。我可以这样做来添加一些文字

filename mymail email   
                        to=('mail@email.com')
                        subject='Report'
                        from='mail@email.com'
                        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;

但我似乎无法做到这两点?如果我包含文本步骤和proc报告,我只会在生成的电子邮件中看到该报告。有什么想法吗?

提前致谢:)

2 个答案:

答案 0 :(得分:1)

如果有人有兴趣,我设法通过在proc报告之前直接添加以下行来解决这个问题:

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;

答案 1 :(得分:1)

将文本添加到HTML文件中的解决方案听起来效果最佳。

您的原始代码存在两个问题。

首先,您有访问冲突。 DATA _NULL_步骤正在尝试写入ODS HTML进程仍在写入的同一文件。你没有收到错误信息吗?或者两个单独的电子邮件?

第二,即使您成功将文本写入与ODS HTML生成的文件相同的文件中,也可以是在ODS HTML生成的报告周围的<HTML> .. </HTML>标记之前或之后。因此,收件人可能会忽略它。