Page 1 of 1

Help in finding the corresponding date of an observation

Posted: Thu Mar 08, 2018 3:57 pm
by sudesh
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.

Re: Help in finding the corresponding date of an observation

Posted: Thu Mar 08, 2018 4:54 pm
by EViews Matt
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?

Re: Help in finding the corresponding date of an observation

Posted: Fri Mar 09, 2018 6:39 am
by sudesh
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.

Re: Help in finding the corresponding date of an observation

Posted: Fri Mar 09, 2018 9:58 am
by EViews Matt
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

Posted: Mon Mar 12, 2018 7:26 am
by sudesh
Thanks alots, it's working