正确结束 SAS 存储的进程 [英] Ending a SAS-Stored process properly

查看:20
本文介绍了正确结束 SAS 存储的进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SAS-Storedprocess,它通过 webout 进行一些 html 输出.在某些情况下(例如:没有可用数据)我想放置一条自定义错误消息并阻止该进程进一步执行.

I have a SAS-Storedprocess which does some html-output via webout. Under some circumstances (e.G.: no data available) i want to put a custom error message and stop the process from further execution.

我有一个到目前为止运行良好的 makro 解决方案:

I have a makro-solution which had worked fine so far:

%if &varnobs = 0 %then %do;
 data _null_;
    file _webout;   
    put " &text1";
    put " &text2";
    put " &text3";
 run;
ENDSAS; 
%end;

但现在我被告知,我们公司不允许使用 ENDSAS,因为它会产生各种副作用,并且不仅可以停止流程,还可以停止整个会话.

But now i was informed that the use of ENDSAS is not allowed within our company because it can have various side-effects and also can stop not only the process, but also the complete session.

现在我正在寻找替代方案,我也尝试了带有多个选项的 abort 语句,但存在一个问题,即 abort 在日志中放置一条错误消息,因此不会显示我的自定义消息,而是显示 sas 错误信息.在中止文档中还声明了 (abort),中止不仅会停止进程,还会停止会话.

Now i am looking for alternatives, i had also tried the abort statement with several options, but one problem there was, that abort puts an error message in the log, so that not my custom message is shown, but a sas error message. Also in the abort documentation is stated (abort), that abort not only stops the process, but also the session.

我知道有诸如 if-else 或 goto 之类的编程替代方法,而不是停止进程,但这不是针对我的特定问题的选项.

I know there are programatically alternatives like if-else or goto instead of stopping the process, but that is not an option for my specific problem.

所以问题是:

如何在执行期间停止存储过程,而不停止会话,没有其他副作用并且没有 SAS 错误消息?

How to stop a stored process during execution, without stopping the session, without other side effects and without an SAS error-message?

推荐答案

确实,endsas; 在某些 SAS 环境中可能会导致无法恢复的问题,尤其是 9.4m3

Indeed, endsas; can cause unrecoverable issues in some SAS environments, particularly 9.4m3

出于这个原因,在 SASjs Core 库中,我们不得不采用开箱即用"的方法来防止进一步执行

For that reason in the SASjs Core library we had to resort to an 'out of the box' method for preventing further execution

我们称之为skippy";- 只需打开一个(或两个)宏,不要关闭它们!

We call it "skippy" - simply open a macro (or two) and don't close them!

filename skip temp;
data _null_;
  file skip;
  put '%macro skip(); %macro skippy();';
run;
%inc skip;

这是我们在 SASjs 中使用的完整宏:https://github.com/sasjs/core/blob/main/base/mp_abort.sas

This is the full macro we use in SASjs: https://github.com/sasjs/core/blob/main/base/mp_abort.sas

这篇关于正确结束 SAS 存储的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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