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

st: creating count within id & date


From   "Richard Hiscock" <[email protected]>
To   <[email protected]>
Subject   st: creating count within id & date
Date   Sun, 27 Feb 2005 16:02:05 +1100

Dear Statalist,

I have the following data structure

id date var1 var2

1 16267 x 53
1 16267 y 106
1 16267 y 84
1 16267 y 90
1 16267 z 76
1 16267 z 65
1 16298 x 87
1 16298 y 76
2 15678 x 98
2 15678 y 98
2 16541 x 150

etc
I wish to create identifier (visitno) 1,2,3,... for each sequential date within id.
I have tried to use :
sort id date
by id date: gen visitno = [_n] which obviously doesnt produce the required variable
I would be greatful for solution & ?or direction to FAQ dealing with this
Cheers Richard



*
* 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