Hi, I have a time series and want to create a dummy variable based on the number of observations in time=1 and compare it with the number of observation in time 2. Consider the following data::
In the above table for time 1 , stock a the obscount is 22 , then the output dummy variable=1 if the obscount for stock a in time 2 is also 22, otherwise it will be zero.
In the above example for stock b, the dummy variable output should be 0 considering above condition. This should be repeated for all t separately, (time 2 obscount will be compared with time 3). Also, in case the stock is missing in the next time series the dummy variable should be 0.)
Kindly help with this (hope I am clear in conveying what I want). Thank you in advance.
| time | Stock | obscount |
| 1 | a | 22 |
| 1 | b | 21 |
| 1 | c | 20 |
| 1 | d | 22 |
| 1 | e | 22 |
| 1 | f | 22 |
| 2 | a | 22 |
| 2 | b | 22 |
| 2 | c | 23 |
| 2 | d | 19 |
| 2 | e | 22 |
| 2 | f | 18 |
| 3 | a | 21 |
| 3 | b | 20 |
| 3 | c | 23 |
| 3 | d | 17 |
| 3 | e | 22 |
| 3 | f | 22 |
| 3 | g | 22 |
In the above example for stock b, the dummy variable output should be 0 considering above condition. This should be repeated for all t separately, (time 2 obscount will be compared with time 3). Also, in case the stock is missing in the next time series the dummy variable should be 0.)
Kindly help with this (hope I am clear in conveying what I want). Thank you in advance.

Comment