Statalist The Stata Listserver


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

Re: st: First occurence


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <n.j.cox@durham.ac.uk> 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
n.j.cox@durham.ac.uk
*
*   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