Hi,
I have a series with the following observations: NA, 0 , 1 and values > 1.
The 1 represent the entry date and the value > 1 represent the exit date
In the series, I have severals entry and exit dates.
I would like to extract all entry and exit dates and save them into a table.
I need to save them into a table, because I will use the entry and exit date to calculate the return of each period
I don't know how to retrieve the corresponding dates and how to store them into a table.
Any help will be greatly appreciated.
Help in finding the corresponding date of an observation
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Help in finding the corresponding date of an observation
Hello,
Are the periods defined by each entry/exit date pair non-overlapping? In other words, are there never two entry dates without an exit date between them, and vice versa?
Are the periods defined by each entry/exit date pair non-overlapping? In other words, are there never two entry dates without an exit date between them, and vice versa?
Re: Help in finding the corresponding date of an observation
Hi,
Each entry date is followed by an exit date , non overlapping period
For exemple, the first date is always an entry date( 01 jan 1970), the next is an exit date ( 01 mars 1970) and then the second entry date might be ( 01 june 1980) and so on.
Each entry date is followed by an exit date , non overlapping period
For exemple, the first date is always an entry date( 01 jan 1970), the next is an exit date ( 01 mars 1970) and then the second entry date might be ( 01 june 1980) and so on.
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Help in finding the corresponding date of an observation
This should get you started.
Code: Select all
series tmp = @obsid
' Create a two-column matrix where the first column holds entry observation numbers and the second column holds exit observation numbers. Assumes the series of interest is called "x".
matrix m = @transpose(@unvec(@convert(tmp, "if x >= 1"), 2))
' Convert the matrix into a table, changing observations to dates along the way.
table t
for !r = 1 to @rows(m)
t(!r, 1) = @otod(m(!r, 1))
t(!r, 2) = @otod(m(!r, 2))
next
delete tmp m
Re: Help in finding the corresponding date of an observation
Thanks alots, it's working
Who is online
Users browsing this forum: No registered users and 35 guests