Page 1 of 1

Replace NA with last non-NA value in series

Posted: Thu Feb 05, 2015 8:15 am
by elias41
Hi,

is there an efficient way to exchange all NAs with the respective last non-NA value in a series?

Looping through all elements does not seem too promising from an efficient point of view.

Re: Replace NA with last non-NA value in series

Posted: Thu Feb 05, 2015 8:37 am
by EViews Gareth

Code: Select all

x = @recode(x=na, @last(x), x)

Re: Replace NA with last non-NA value in series

Posted: Thu Feb 05, 2015 8:46 am
by elias41
great - works! Many thanks.