Page 1 of 1

Error Handling: WFCLOSE and TRY

Posted: Thu Aug 29, 2013 3:59 am
by BrsG
[Using version 8]

Hi there,

I am missing a few essential features in Eviews related to error handling, in particular an equivalent to the "try" command common to many programming languages.

First, I am aware that there is the possibility of using the error count. But this is often cumbersome.

WFCLOSE: wouldn't it be possible to change this command for Eviews to try to close any open WF? Currently I have to comment it in an out while debugging. Would it be possible to extend the "noerr" option to the case where no name is given? Btw, even in the case where a name is given the "noerr" options doesn't seem to work for me (in the code below). Am I doing something wrong?

Code: Select all

cd %path wfclose(noerr) pr wfcreate(wf=pr,page=raw) M 1980M1 2020M12
Equation estimation: It happens sometimes that I want to estimate a large number of equations with the same structure, without checking beforehand whether all the data involved are well behaved. I would ideally want to use something like

Code: Select all

for !k = 1 to K try eq{!k}.ls {eqstructure} next
In the above using error counts might still be workable (although it also doesn't seem to work for every error), but if I have block of instructions which I want to "try" it quickly gets cumbersome to wrap each instruction with the error count syntax.

Cheers,
Boris

Re: Error Handling: WFCLOSE and TRY

Posted: Thu Aug 29, 2013 7:47 am
by EViews Gareth
As you point out, there is no TRY in EViews.

I'll look into the wfclose issue.

Re: Error Handling: WFCLOSE and TRY

Posted: Thu Aug 29, 2013 8:16 am
by BrsG
Thanks for looking into the wfclose issue.

Regarding "try". The point I was trying to make was that it would be great to have "try".

Re: Error Handling: WFCLOSE and TRY

Posted: Thu Aug 29, 2013 11:16 am
by EViews Glenn
We had a brief discussion of this and the question came up. What exactly is it that you'd like "try" to do?

Re: Error Handling: WFCLOSE and TRY

Posted: Tue Feb 11, 2014 8:00 am
by mboldin
Let me make a suggestion in this regard

I think it would be useful to have a conventional try - except - else type ability (the Pythonic way is worth looking at http://docs.python.org/2/tutorial/errors.html as an example)

While the method below can be adopted to probably handle 90% or more of the applications or error ahandling, it would be better to use error catching by type and to have a try part that handles a block of code, as opposed to having error checking after every line of code that needs checking. I.e., I would prefer to write code as in the second example

'Current way
fetch (d=mydata) {%x} ' %x from from loop
if @lasterrnum=0 then
'no fetch error, so skip ahead or do something such as compute mean of %X or add to an accumulating sum
else
genr {%x}= @na 'set all series values as missing
'more error handling
endif


'Better way IMHO
try
fetch (d=mydata) {%x} ' %x from from loop
!amean= @mean({%x}
genr y_{%x} = y / !amean
except fetch_error_code
genr {%x}= @na 'set all series values as missing
genr y_{%x}= @na
'more error handling
except divide_by_zero_error
genr y_{%x}= @na 'set series as missing
else
'no error, so do something or not ...
endtry