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

st: RE: bysort group: gen time = _n


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: bysort group: gen time = _n
Date   Fri, 21 Nov 2003 20:05:48 -0000

No reason why it should. 

. bysort group : gen time = _n 

will in general produce quite 
arbitrary values for -time-, 
just as would 

. sysuse auto
. bysort rep78 : gen time = _n 

You're more likely to want something like

. bysort group (year) : gen time = _n 

That is, for this to make sense, some 
other variable must be available 
to indicate the order _within_ groups.  

Nick 
n.j.cox@durham.ac.uk 

Clive Nicholas
 
> Unfortunately, -bysort group: gen time = _n- didn't do the 
> trick, as I
> suspected it mightn't. That's the variable that, when 
> generated, produces
> the "repeated time values within panel r(451);" error. :( I 
> should have
> been a bit clearer on that earlier!

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index