I was curios if i am able to turn the division by zero note to an error. (i.e. NOTE: Division by zero detected at line xx column xx. OR NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values.) For example, I usually use the following options: options varinitchk=error mprint=1 validvarname=v7 missing='' ; where varinitchk=error is the sort of option I am looking for.
Thanks,
Joe
If you use divide(a,b) instead of a/b then the case of division by 0 will yield a .I (special missing value -- .I for Inf, .M for -Inf). You can then flag those instances with a variable "myerror":
data _null_;
ex1=1/0;
put ex1=;
ex2=divide(1,0);
put ex2=;
myerror = (ex2 in (.I .M));
put myerror=;
run;
I am more of looking for the program to stop running because of errors. Not just put a new note in the log. Thanks for the thought though.
Maybe NOTE2ERR data statement option.
35 data _null_ / note2err;
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
ERROR: Division by zero detected during the compilation phase, detected at line 36 column 9.
NOTE: The SAS System stopped processing this step because of errors.
36 x = 1/0;
37 run;
38 data _null_ / note2err;
39 d = 0;
40 x = 1/d;
41 run;
ERROR: Division by zero detected at line 40 column 9.
ERROR: Termination due to Floating Point Exception
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
Is there anyway to apply note2err to a specific note and across all datasets?
option dsoptions=note2err;
option dsoptions=note2err;
data _null_;
a=1/0;
run;
You can use the internal option DSOPTIONS=note2err; to apply to all data steps. I don't know if you can make it specific to division by zero.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.