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 :)
fill series until next value
Moderators: EViews Gareth, EViews Moderator
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fill series until next value
Code: Select all
series x = @recode(x=0, x(-1), x)
Re: fill series until next value
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!
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: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fill series until next value
Sorry, went the wrong way.
Code: Select all
genr(r) x = @recode(x=0, x(1), x)
Re: fill series until next value
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: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fill series until next value
Generate backwards through time (i.e. start at the last date and go to the first)
Re: fill series until next value
Is there an option for generating forward through time as well?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fill series until next value
That's what happens naturally.
Return to “General Information and Tips and Tricks”
Who is online
Users browsing this forum: No registered users and 2 guests
