1

虽然我有错误处理:

filename myfile email                                                                                                                   
to=&e_mail.                                                                                                               
subject= "Error: &number."                                                                                                              
type="text/plain";  

%macro errmail;                                                                                                                         
 %if &syserr ne 0 %then %do;  
 options obs= max replace nosyntaxcheck; 
  data _null_;        
   file myfile;                                                                                                                                                                                               
   put;                                                                                                                                 
   put 'ERROR';                                                                                                                    
   put "&syserrortext";                                                                                                                 
   put 'check a log'
  run;       
 %abort cancel;  
 %end;                                                                                                                                  
%mend errmail;

当我在 proc 导出中遇到错误时:(&number。是工作中的表)

proc export data=&number.
outfile="/usr/local/backup/&number./&number._%SYSFUNC(TODAY(),DATE9.).txt"
replace
dbms=dlm; 
delimiter=';';
 run;
 %errmail;

ERROR: Physical file does not exist, /usr/local/backup/2116/2116_13MAY2016.txt.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.2116.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

SAS 不检查宏,也不发送电子邮件。我的路径有错误,所以我理解错误,但我需要一封关于此的电子邮件,我希望 SAS 由于宏而停止处理。在宏中添加一些选项可以修复它吗?

4

1 回答 1

0

这就是我从 SAS 发送电子邮件的方式

不需要在系统上创建文件

filename outbox email "email@address.com"; 
data _null_;    
file outbox    
to=("email@address.com")     
cc=("email@address.com")    
subject="SUBJECT OF EMAIL "    
/* attach=("C:\sas\results.out" "C:\sas\code.sas")  */    ; /* incase you need to attach a file */    
put 'Hello! ';    
put ' '; 
put 'Thank you & let me know if there is anything,';
put "&macrovar.";   /*in case you need to put some detail in the email from macro variables   make sure to use double quote for that */
put 'SIGNATURE ME'; 
run;
于 2018-12-06T17:13:36.017 回答