NA in "if" statement

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

utah777
Posts: 13
Joined: Thu Aug 19, 2010 1:34 pm

NA in "if" statement

Postby utah777 » Wed Oct 13, 2010 12:59 pm

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?

tchaithonov
Posts: 168
Joined: Mon Apr 13, 2009 7:39 am
Location: New York City

Re: NA in "if" statement

Postby tchaithonov » Wed Oct 13, 2010 2:12 pm

use @recode instead.

utah777
Posts: 13
Joined: Thu Aug 19, 2010 1:34 pm

Re: NA in "if" statement

Postby utah777 » Wed Oct 13, 2010 11:50 pm

@recode will work for the first time, but when I use it for the second, it will overwrite the first results.
Any other suggestions?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13584
Joined: Tue Sep 16, 2008 5:38 pm

Re: NA in "if" statement

Postby EViews Gareth » Wed Oct 13, 2010 11:59 pm

Code: Select all

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

utah777
Posts: 13
Joined: Thu Aug 19, 2010 1:34 pm

Re: NA in "if" statement

Postby utah777 » Thu Oct 14, 2010 12:38 am

Thank you for the help


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest