SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1321|回复: 8
打印 上一主题 下一主题

关于系统变量_error_的问题。

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2004-2-25 23:47:30 | 只看该作者

关于系统变量_error_的问题。

系统变量_error_在数据步中的具体作用是什么?
如果人为的令:_error_=0,会发生什么样的结果?

望各位不吝赐教,谢谢!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2004-2-26 08:40:00 | 只看该作者
_ERROR_ is a system variable and it is used to control the job flow of a SAS session.  Anytime when there is a system error, SAS turns _ERROR_ flag on.  I believe that it is not an (0,1) variable, it may have multiple levels.  The larger the number, the more serious of the problem.  When the number reaches the threshhold, SAS system will terminate the current session and return to control panel.  Set _ERROR_ to 0, I do not think it will work.  First, you have to try if you can change value of a system variable; Second, you can only assign a value to a variable in data step, but _ERROR_ variable exists during the running of procedures.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2004-2-26 12:11:48 | 只看该作者
这是个系统变量,一般scl中用于检查一个过程是否出错.

init:
   dcl num rc;

   proc ....
   run;

   rc=symgetn('_error_');
   if rc=1 then put "Error occurred during the procedure!";
   else put "Eventhing is Ok!"
return;
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2004-2-26 20:25:39 | 只看该作者
谢谢二位的指点,你们的回答令我很是受益。谢谢!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
5#
 楼主| 发表于 2004-2-26 21:38:58 | 只看该作者

Re: 关于系统变量_error_的问题。

[quote="student":d74f3]系统变量_error_在数据步中的具体作用是什么?
如果人为的令:_error_=0,会发生什么样的结果?

望各位不吝赐教,谢谢![/quote:d74f3]

One is often surprised that the user can chage an automatic variable.Actually automatic variable such as _error_  can be modified by user in anyway chosen.However  it's interesting,you will find,that the value that you set to automatic variable _error_ don't critically influence the job flow of sas session.There seem to be an implied mechanism that can be used by sas system  to determine the true value of automatic variable _error_.The fact can be easily demonstrated with the code below.

data _null_;
  put "top:" _all_;
  input a;
  _n_+7;
  _error_+(-1);
  put "bot:" _all_;
  cards;
  1
  2
  3
  ;
run;

------------------------------------
log:

100  data _null_;
101     put "top:" _all_;
102     input a;
103     _n_+7;
104     _error_+(-1);
105     put "bot:" _all_;
106     cards;

top:a=. _ERROR_=0 _N_=1
bot:a=1 _ERROR_=-1 _N_=8
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-
107           1
a=1 _ERROR_=-1 _N_=8
top:a=. _ERROR_=0 _N_=2
bot:a=2 _ERROR_=-1 _N_=9
108           2
a=2 _ERROR_=-1 _N_=9
top:a=. _ERROR_=0 _N_=3
bot:a=3 _ERROR_=-1 _N_=10
109           3
a=3 _ERROR_=-1 _N_=10
top:a=. _ERROR_=0 _N_=4
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
6#
 楼主| 发表于 2004-2-26 23:34:20 | 只看该作者
谢谢forestshen的精彩回答,希望以后能给与更多指教!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
7#
 楼主| 发表于 2004-2-28 17:01:29 | 只看该作者
楼上的大侠回答的太好了,深有收获.但是,_n_的值在a=2和a=3时,为何不是16,24阿?
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
8#
 楼主| 发表于 2005-12-28 10:24:53 | 只看该作者

Re: 关于系统变量_error_的问题。

[quote="forestshen":cea84]There seem to be an implied mechanism that can be used by sas system  to determine the true value of automatic variable _error_.The fact can be easily demonstrated with the code below.

[/quote:cea84]
I guess this is not a proper definition of the way SAS setting values to _error_. Below is my understanding.
It is not a "true" value SAS can see here. It is just because when SAS perform a "task" required error-check SAS will reset the value of _error_ to 0 or 1 based on the performance. the “task” here is “input”. it will overwrite the previous value of _error_. so you could not say SAS is powerful enough to see the true value of _error_. It is just an automatic variable it is not a magic variable.
[code:cea84]data ahuige;
  put 'before input' _error_=;
  input var;
  put 'after input' _error_=;
  cards;
1
d
1
4
;
run;[/code:cea84]
[quote:cea84]
35   data ahuige;
36     put 'before input' _error_=;
37     input var;
38     put 'after input' _error_=;
39     cards;

before input_ERROR_=0
after input_ERROR_=0
before input_ERROR_=0
NOTE: Invalid data for var in line 41 1-1.
after input_ERROR_=1
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
41         d
var=. _ERROR_=1 _N_=2
before input_ERROR_=0
after input_ERROR_=0
before input_ERROR_=0
after input_ERROR_=0
before input_ERROR_=0
NOTE: The data set WORK.AHUIGE has 4 observations and 1 variables.
NOTE: DATA statement used:
      real time           0.00 seconds
      cpu time            0.00 seconds


44   ;
45   run;
[/quote:cea84]
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
9#
 楼主| 发表于 2005-12-29 16:05:49 | 只看该作者

i did not look up documents carefully

i know there is a threshold. but it has nothing to do with the value of _error_. there must be another automatic variable to record the times of error occurrence.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-9 10:27 , Processed in 0.074078 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表