I am new to Eviews programming (with Eviews 6) and I have the following question:
I have time series data with events on certain dates marked by 0's and 1's. I would like to count the number of time periods between each event. For example, I would like the first period after an event to be 1, the second period 2, etc., until the next event when the count will reset at 0. Is there a way to do this? I have tried using loops and if/then logic but have been unsuccessful.
Thank you.
counting periods after marked dates
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: counting periods after marked dates
Assuming you have a series called "EVENT" that has a 1 every time there is an event, and 0 otherwise, the counter could be generated with:
It might mess up if the very first observation of the workfile has a an event.
Code: Select all
series counter = @recode(event=1,counter(-1)+1,0)
Re: counting periods after marked dates
thank you very much for the reply - it was very helpful.
For future reference though, the condition was switched. If 1 is the event, then we want to increment when event = 0 as shown below.
series counter = @recode(event=0,counter(-1)+1,0)
For future reference though, the condition was switched. If 1 is the event, then we want to increment when event = 0 as shown below.
series counter = @recode(event=0,counter(-1)+1,0)
Who is online
Users browsing this forum: No registered users and 1 guest
