Page 1 of 1

NA in "if" statement

Posted: Wed Oct 13, 2010 12:59 pm
by utah777
I'm trying to assign +1 values to a 'trade' series when my 'res' (=residual) series is greater than standard deviation (=s) and -1 when my 'res' series less than negative standard deviation

if res>s then
series trade=1
else
if res<-s then
series trade=-1
endif
endif

but getting a message "NA found in matrix IF RES>S then"

Is there a way to avoid the NA message?

Re: NA in "if" statement

Posted: Wed Oct 13, 2010 2:12 pm
by tchaithonov
use @recode instead.

Re: NA in "if" statement

Posted: Wed Oct 13, 2010 11:50 pm
by utah777
@recode will work for the first time, but when I use it for the second, it will overwrite the first results.
Any other suggestions?

Re: NA in "if" statement

Posted: Wed Oct 13, 2010 11:59 pm
by EViews Gareth

Code: Select all

series trade = @recode(res>s, 1, 0) series trade = @recode(res<-s,-1,trade)

Re: NA in "if" statement

Posted: Thu Oct 14, 2010 12:38 am
by utah777
Thank you for the help