Page 1 of 1

fill series until next value

Posted: Sun Oct 30, 2016 5:43 am
by Gin
Hi all,

I have a data series for event-study. I need to fill/replace the zeros in a series with the value on event days, so that the entries until the release of the next value stay constant. The data are of daily frequency and the tim interval of release dates are irregular.

For example
series1
0
0
0
2.5
0
0
1.5
0
0
0
0
1.9

I need to have a series like
2.5
2.5
2.5
2.5
1.5
1.5
1.5
1.9
1.9
1.9
1.9
1.9

I would appreciate any ideas :)

Re: fill series until next value

Posted: Sun Oct 30, 2016 1:36 pm
by EViews Gareth

Code: Select all

series x = @recode(x=0, x(-1), x)

Re: fill series until next value

Posted: Sun Oct 30, 2016 11:02 pm
by Gin
Hi Gareth,

that will replace only the entry before the non-zero one with the non-zero value (via the argument x(-1)).
The series then looks like
0
0
2.5
2.5
0
1.5
1.5
0
0
0
1.9
1.9

How can I fill all the zero entries with the next non-zero values? so the series looks like
2.5
2.5
2.5
2.5
1.5
1.5
1.5
1.9
1.9
1.9
1.9
1.9

Thanks!

Re: fill series until next value

Posted: Mon Oct 31, 2016 8:22 am
by EViews Gareth
Sorry, went the wrong way.

Code: Select all

genr(r) x = @recode(x=0, x(1), x)

Re: fill series until next value

Posted: Mon Oct 31, 2016 8:37 am
by Gin
Thanks, Gerath! that worked well. Can you please tell me what the option (r) in genr(r) does? I couldn't find an explanation in the Eviews help file.

Re: fill series until next value

Posted: Mon Oct 31, 2016 9:54 am
by EViews Gareth
Generate backwards through time (i.e. start at the last date and go to the first)

Re: fill series until next value

Posted: Mon Oct 31, 2016 11:15 am
by Gin
Is there an option for generating forward through time as well?

Re: fill series until next value

Posted: Mon Oct 31, 2016 11:44 am
by EViews Gareth
That's what happens naturally.