Replace NA with last non-NA value in series

For questions regarding programming in the EViews programming language.

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

elias41
Posts: 25
Joined: Mon Jun 10, 2013 1:20 am

Replace NA with last non-NA value in series

Postby elias41 » Thu Feb 05, 2015 8:15 am

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.

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

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

Postby EViews Gareth » Thu Feb 05, 2015 8:37 am

Code: Select all

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

elias41
Posts: 25
Joined: Mon Jun 10, 2013 1:20 am

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

Postby elias41 » Thu Feb 05, 2015 8:46 am

great - works! Many thanks.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests