Page 1 of 1

Replace NA by 0

Posted: Tue Oct 12, 2010 6:55 am
by MoneyMarcus
Hi,
my series contains 1641 observations and some of them are NA-entries. I want to write a program that replaces them by zero. I tried it this way:

for !i = 1 to 1641
if @isna(@elem(series, !i)) then
@elem(series, !i} = 0
endif
next

Unfortunately, my code returns an error message, telling me that "an unnamed object cannot be converted to a string in IF...". What shall I do?

Replace NA by 0

Posted: Tue Oct 12, 2010 7:06 am
by EViews Gareth

Code: Select all

X=@recode(X=na,0,X)

Re: Replace NA by 0

Posted: Tue Oct 12, 2010 7:26 am
by tchaithonov

Code: Select all

X=@nan(X,0)

Re: Replace NA by 0

Posted: Tue Oct 12, 2010 7:30 am
by MoneyMarcus
Great, thanks for your fast help!

Re: Replace NA by 0

Posted: Tue Jul 17, 2012 11:41 am
by canboardrp
I got a number of series where I have this same problem and I've tried the recode approach as below and it hasn't worked. I'm still left with NA's in the series and it's throwing things off for me.

Code: Select all

Nonwork=@recode(na,0,0)
What have I got wrong in the programming?

Re: Replace NA by 0

Posted: Tue Jul 17, 2012 1:37 pm
by EViews Gareth
Looks like you got the syntax wrong:

Code: Select all

X=@recode(X=na,0,X)