我使用索引来避免重复每次数据集更新并根据失败和成功发送邮件。以下是代码。
data lib.new(index =(dual=(name date)/ unique));
set lib.old;
run;
options emailsys=smtp;
%macro sendmail;
%if &syserr ne 0 %then %do;
data _null_;
filename mailbox EMAIL 'abc@gmail.com' subject ='Failed';
file mailbox;
put "Data already avaialable. Please submit for different";
run; %end;
%else %do; data _null_;
filename mailbox EMAIL 'abc@gmail.com' subject ='Success';
file mailbox;
put "Data created"; run; %end;
%mend sendmail;
%sendmail;
当我运行上面的代码。数据更新成功后,我可以收到邮件。但是当我没有收到邮件时,
还有其他办法吗?
为了成功。我通过电子邮件详细信息和邮件触发了以下日志。
SYMBOLGEN: Macro variable SYSERR resolves to 0
MACROGEN(SENDMAIL): data _null_;
MACROGEN(SENDMAIL): filename mailbox EMAIL 'abc@gmail.com' subject 'Success';
MACROGEN(SENDMAIL): file mailbox;
MACROGEN(SENDMAIL): put "Data created";
MACROGEN(SENDMAIL): run;
NOTE: The file MAILBOX is:
E-Mail Access Device
Message sent
To: "abc@gmail.com"
The SAS System
Cc:
Bcc:
Subject: Job Success
Attachments:
NOTE: 1 record was written to the file MAILBOX.
失败。我收到了日志,邮件没有被触发
SYMBOLGEN: Macro variable SYSERR resolves to 1012
MACROGEN(SENDMAIL): data _null_;
MACROGEN(SENDMAIL): filename mailbox EMAIL 'abc@gmail.com' subject ='Job Failed';
MACROGEN(SENDMAIL): file mailbox;
The SAS System
MACROGEN(SENDMAIL): put "Data already available. Please submit for different";
MACROGEN(SENDMAIL):run;
答案 0 :(得分:0)
filename
语句应该在data step
之前。试试这个。
options emailsys=smtp;
%macro sendmail;
filename mailbox EMAIL 'abc@gmail.com';
data _null_;
file mailbox;
%if &syserr ne 0 %then %do;
put '!em_subject! "Failed"';
put "Data already avaialable. Please submit for different";
%end;
%else %do;
put '!em_subject! "Success"';
put "Data created";
%end;
run;
%mend sendmail;
%sendmail