Dear Statalist members,
I have a question regarding the definition of a new variable in a data
set. I would like to define this new variable in the way that it will
tell me how many subjects with a specific characteristic exist at a
specific time. For example: Suggesting a simplified data set of nine
subjects with information regarding their market-entry, market-exit, and
size. In this case, I would like to know how many subjects with the size
6 were in the market at the same time with each other subject.
Example:
ID Market-Entry Market-Exit Size
New_Variable
1 10 98 1
1
2 15 80 1
0
3 30 110 1
2
4 41 97 1
1
5 76 85 1
1
6 77 218 2
2
7 85 220 3
2
8 82 118 6
2
9 99 218 6
2
For ID1, for example, subject 8 entered at time 82, while ID1
markets-exist is 98. The other subject with size 6 is ID9. But ID9
entered the market after the market-exist of ID1. So the variable should
hold the value 1 (One subject with size 6 was present in the market at
the same time as ID1). Regarding subject ID2, ID8 and ID 9 entered after
the market-exit of ID2, so the new variable should hold the value 0. For
ID3, the new variable should hold the value 2, because both subjects
with the size 6 were present in the market at the same time than ID3,
and so on.
I really appreciate for any help and suggestions.
Simon
*
* 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/