SAS%错误信息宏

时间:2016-05-13 09:55:56

标签: sas 4gl

虽然我有错误处理:

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因宏而停止处理。 向宏添加一些选项可以修复它吗?

1 个答案:

答案 0 :(得分: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;