Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Timevarying IDs in a panel dataset


From   Daniel H�chle <[email protected]>
To   <[email protected]>
Subject   st: Timevarying IDs in a panel dataset
Date   Tue, 22 Nov 2005 15:39:09 +0100

Dear all

I do have a panel of several thousand stocks. Each stock has an id
called ID_now. However, there is a problem: The stock's id may change
over time. Therefore, I do have variable ID_nextperiod which contains
the stock's id in the next period. The data looks like this:

Date       ID_now       ID_nextperiod         Price_now
 1           1               1                    100
 2           1               1                    110
 3           1               1                    105
 4           1               1                    100
 3           2               2                     22
 4           2               2                     27
 1           3               3                     20
 2           3               2                     25
 1           4               5                     60
 2           5               5                     65
 3           5               5                     67
...

What I would like to do is calculating the discrete stock returns. If
the stock's ID would not change over time this could be achieved (after
tssetting the dataset) by simply typing

. PriceRet = Price_now / L.Price_now - 1

However, I do not have any idea how to calculate the discrete stock
returns in case of changing IDs. Any ideas would be appreciated.

Best,
Daniel

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index