有没有办法让 SAS 在第一次警告或错误时停止? [英] Is there a way to make SAS stop upon the first warning or error?

查看:43
本文介绍了有没有办法让 SAS 在第一次警告或错误时停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SAS 喜欢在出现警告和错误后继续处理,因此我经常需要回滚日志中的页面以查找问题.有没有更好的办法?我希望它在出现第一个错误或警告时立即停止,以便我可以修复它并重试.

SAS likes to continue processing well after warnings and errors, so I often need to scroll back through pages in the log to find an issue. Is there a better way? I'd like it to stop as soon as the first error or warning appears so I can fix it and try again.

推荐答案

之前建议使用 ERRORS=1 选项,但这只会阻止 ERROR 消息写入日志.我建议使用另一个系统选项 ERRORABEND,它会阻止程序对大多数错误进行进一步处理.我不知道由于警告而终止处理的选项,但我认为您可以添加如下所示的宏来停止处理.

The ERRORS=1 option was previously suggested, but that only stops he ERROR messages from writing to the log. I would suggest another system option ERRORABEND which will stop the program from further processing for most errors. I don't know of an option to terminate processing due to warnings, but I think that you could add a macro like the following to stop processing.

%macro check_for_errors;
   %if &syserr > 0 %then %do;
      endsas;
   %end;
%mend check_for_errors;

data test1;
    <data step code>
run;
%check_for_errors;

您可以在程序的每一步之后重复宏调用,并且它应该在错误代码不是 0 时终止.

You could repeat the macro call after each step of your program, and it should terminate at the point that the error code is anything but 0.

这篇关于有没有办法让 SAS 在第一次警告或错误时停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆