Avoiding divide by zero errors
Posted: Fri Oct 08, 2010 9:34 am
I'm trying to find a way of avoiding errors when dividing one series by another, when the latter series may contain zero values.
I would expect the @recode function to be the answer, but if I run this sample program:
I still get a divide by zero error, although the series Z is correctly computed.
The only ways round it that I have found are either to run the program with the maximum errors option set to some suitable value >1, which risks masking other errors, or to write an if statement using the @elem function to test each value of x in turn, which is potentially slow and inelegant.
Is there a better solution? I'm using EViews 7.
Thanks
Geoff
I would expect the @recode function to be the answer, but if I run this sample program:
Code: Select all
series x = 2
x(1) = 0
series y = 1
series z = @recode(x=0,na,y/x)The only ways round it that I have found are either to run the program with the maximum errors option set to some suitable value >1, which risks masking other errors, or to write an if statement using the @elem function to test each value of x in turn, which is potentially slow and inelegant.
Is there a better solution? I'm using EViews 7.
Thanks
Geoff