如何在不向日志发送错误消息的情况下有条件地停止执行SAS脚本?

时间:2014-12-23 13:36:34

标签: sas

我希望有类似的东西,但我不希望在退出时将错误消息发送到SAS日志。

data test_table;
     input numbers;
     datalines;
1
2
3
4
5
;
run ;

proc sql;
     select count(*) into :recordsCount
     from test_table;
quit;

%macro abortIfRemaining;
     %if (&recordsCount > 0) %then %do;
           %abort return 0;
     %end;

     %put No records found;
%mend abortIfRemaining;

* More code blocks would go here if no records found ;

%abortIfRemaining;

1 个答案:

答案 0 :(得分:2)

找到我正在寻找的命令。这是" endsas"。

data test_table;
     input numbers;
     datalines;
1
2
3
4
5
;

proc sql;
     select count(*) into :recordsCount
     from test_table;
quit;

%macro abortIfRemaining;
     %if (&recordsCount > 0) %then %do;
           endsas;
     %end;

     %put No records found;
%mend abortIfRemaining;

* More code blocks would go here if no records found ;

%abortIfRemaining;