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

st: RE: how to use lag function to create sequential number


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: how to use lag function to create sequential number
Date   Sun, 11 Sep 2005 19:17:06 +0100

I am not aware of a lag function, i.e. -lag()-, in Stata. There is 
a lag operator L. but that is not appropriate for your purpose. 

You may be in search of 

bysort race : gen id = _n 

or 

bysort race : egen id = seq() 

although note that the labelling produced is essentially arbitrary
in either case. 

Nick 
[email protected] 

[email protected]
 
> for example, there are 17 people who have the same ethnicity. 
> If I want to give
> them a sequential number 1 2 3..........17, how can I use lag 
> function to do this?

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