fill series until next value

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

Gin
Posts: 22
Joined: Wed Oct 19, 2016 10:26 am

fill series until next value

Postby Gin » Sun Oct 30, 2016 5:43 am

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 :)

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

Re: fill series until next value

Postby EViews Gareth » Sun Oct 30, 2016 1:36 pm

Code: Select all

series x = @recode(x=0, x(-1), x)
Follow us on Twitter @IHSEViews

Gin
Posts: 22
Joined: Wed Oct 19, 2016 10:26 am

Re: fill series until next value

Postby Gin » Sun Oct 30, 2016 11:02 pm

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!

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

Re: fill series until next value

Postby EViews Gareth » Mon Oct 31, 2016 8:22 am

Sorry, went the wrong way.

Code: Select all

genr(r) x = @recode(x=0, x(1), x)
Follow us on Twitter @IHSEViews

Gin
Posts: 22
Joined: Wed Oct 19, 2016 10:26 am

Re: fill series until next value

Postby Gin » Mon Oct 31, 2016 8:37 am

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.

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

Re: fill series until next value

Postby EViews Gareth » Mon Oct 31, 2016 9:54 am

Generate backwards through time (i.e. start at the last date and go to the first)
Follow us on Twitter @IHSEViews

Gin
Posts: 22
Joined: Wed Oct 19, 2016 10:26 am

Re: fill series until next value

Postby Gin » Mon Oct 31, 2016 11:15 am

Is there an option for generating forward through time as well?

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

Re: fill series until next value

Postby EViews Gareth » Mon Oct 31, 2016 11:44 am

That's what happens naturally.
Follow us on Twitter @IHSEViews


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests