Page 1 of 1

Replacing the NAs by the last observation preceding the NA

Posted: Tue Apr 24, 2012 1:27 pm
by Sissy
Hello,

In order to get a continuous sample to run an EGARCH regression, I'd like to replace the NAs by the last observation preceding the NA. How can I do that in Eviews 7 sv, please ?

Thanks in advance.

Re: Replacing the NAs by the last observation preceding the

Posted: Tue Apr 24, 2012 2:00 pm
by EViews Glenn
I'm not going to comment on the econometric issues associated with doing what you propose, but if A is the original series and you want to create a new series Y that has A or the last valid value for A, the following should do it for you.

Code: Select all

series y=@recode(a=na, y(-1), a)
This assumes that the first observation for A is valid.

Re: Replacing the NAs by the last observation preceding the

Posted: Tue Apr 24, 2012 11:22 pm
by Sissy
Very good, it's ok :lol: Thank you very much.

Re: Replacing the NAs by the last observation preceding the

Posted: Thu May 28, 2015 7:58 am
by chris2012
This is a very useful tip, especially for those of us that import long series from external databases. I was wondering whether it would be possible to apply this command of filling NA values (either with lag, lead or 0 values) for all the series contained in the workfile simultaneously (i.e. a short script) and not just one-by-one.
P.S. Those kind of tricks may be a wonderful addition to a future update of EViews, they are real time savers!!

Re: Replacing the NAs by the last observation preceding the

Posted: Thu May 28, 2015 8:28 am
by EViews Gareth

Code: Select all

%list = @wlookup("*", "series") for %j {%list} {%j} = @recode({%j}=NA, {%j}(-1), {%j}) next

Re: Replacing the NAs by the last observation preceding the

Posted: Fri May 29, 2015 2:53 pm
by chris2012
DONE! Thank you for your prompt response. Is there a manual for all the symbols and commands you used to write this loop? In data transformation process, there are several loops that one may find helpful. I know that there exist some, like "EViews 5 Command and Programming Reference" or "EViews j Illustrated", but I find them quite case-specific. Maybe an extensive command index with short examples?
For instance, how to generate new returns series (named 'ret_GDP') for all existing prices variables (named 'GDP') contained in the workfile. It may seem trivial for someone familiar with coding techniques, yet every software has its own language!
Thanks again for your helpful insights!
All the best!

Re: Replacing the NAs by the last observation preceding the

Posted: Fri May 29, 2015 3:10 pm
by EViews Gareth
The Command and Programming Reference, available from the Help menu