全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
12350 11
2013-02-21
经常会遇到这样一些事情,做了一个很大的宏程序,中间有很多data步,很多循环,跑了很长时间,导致日志几十页长。
跑完了之后,首先要看日志有没有错误,拉了几十页慢慢找红色的error,找到错误再慢慢调试代码。

有没有什么方法,可以实现以下功能.
1: 程序跑完后,日志如果有红色的error,自动出来ods界面(或其它弹出界面),提示错误,甚至显示出错误日志位置上下一定区域的日志。
2:有的时候,还想看到warning情况,可否也类似上述error情况给出提示。
3:  因为跑一个程序要好久,可否控制日志出现error后,终止sas执行过程,随后的程序都不再执行。




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-2-22 01:55:48
1.可以将log文件printto到txt文件中,然后在文件中用SCAN,或者index寻找“ERROR”,这样可以找到所有的error message

2.不必将warning专门列出来,有时候warning只是一些类似格式上的错误,不影响下步sas的运行

3.在marco中,我只是用了一步语句“%if &SYSERR > 6 %then %goto STOPLOG;”。至于为什么&syserr是大于6,这只是我自己工作经验总结,然后把STOPLOG放在最后一步,这样就可以跳出macro了。

一点愚见,大家可以讨论。


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-2-22 22:23:15
这是之前一些做法,你看看是否有帮助。。。
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-2-23 10:10:22
tangliang0905 发表于 2013-2-22 01:55
1.可以将log文件printto到txt文件中,然后在文件中用SCAN,或者index寻找“ERROR”,这样可以找到所有的err ...
Good tips:

The errors are usually caused by wrong syntax, or specify a non-exist variable, or say compiling errors.

One alway use run cancel; statement to check the syntax first. See below.

340  data a;
341    set sashelp.class;
342    where age2=0;
ERROR: Variable age2 is not on file SASHELP.CLASS.
343  run cancel;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.A may be incomplete.  When this step was stopped there were 0
         observations and 5 variables.
WARNING: Data set WORK.A was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


344
345  proc means data=sashelp.class;
346  var _all_;
ERROR: Variable Name in list does not match type prescribed for this list.
ERROR: Variable Sex in list does not match type prescribed for this list.
347  run cancel;

WARNING: The procedure was not executed at the user's request.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-2-23 11:43:24
playmore原来贴一个PDF.

%macro RunQuit();
  ;run;quit;
  %if &syserr. ne 0 %then %do;
     %abort cancel;
         %end;
%mend;


data tmp;
   set sashelp.class;
   where age2=0;
%runquit;
data tmp2;
  x=1;
%runquit ;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-2-23 17:01:53
webgu 发表于 2013-2-23 11:43
playmore原来贴一个PDF.

%macro RunQuit();
试了一下,这个不错,可以达到目的,不过syserr=4的时候表示waring,如果出现waring不让停止的话,还要加上ne 4。另外, 不知道怎么把这个宏变成永久的宏,以后使用的时候,直接调用,不写宏代码了。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群