望各位不吝赐教,谢谢!作者: shiyiming 时间: 2004-2-26 08:40
_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.作者: shiyiming 时间: 2004-2-26 12:11
这是个系统变量,一般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;作者: shiyiming 时间: 2004-2-26 20:25
谢谢二位的指点,你们的回答令我很是受益。谢谢!作者: shiyiming 时间: 2004-2-26 21:38 标题: 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作者: shiyiming 时间: 2004-2-26 23:34
谢谢forestshen的精彩回答,希望以后能给与更多指教!作者: shiyiming 时间: 2004-2-28 17:01
楼上的大侠回答的太好了,深有收获.但是,_n_的值在a=2和a=3时,为何不是16,24阿?作者: shiyiming 时间: 2005-12-28 10:24 标题: 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]作者: shiyiming 时间: 2005-12-29 16:05 标题: 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.