Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: First occurence


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: First occurence
Date   Fri, 18 May 2007 10:58:14 -0400

Nick--
To be sure, and -bys- is a marvelous thing, but I was more thinking of

egen minyr=min(year), by(bdsmaster)
gen fyr=(year==minyr)
tab minyr if fyr, mi
codebook minyr
hist minyr if fyr

etc.

On 5/17/07, Nick Cox <[email protected]> wrote:
Quite so.

As you know, but some may not,
the first year can always be used, without
putting it into a variable, in ways like this

bysort bdsmaster (year) : gen years_since_first = year - year[1]

Nick
[email protected]
*
*   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