Statalist The Stata Listserver


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

st: RE: Smallest observation


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Smallest observation
Date   Thu, 30 Mar 2006 07:19:20 -0600

bysort indiv: gen byte index =_n != 1

Scott


> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of chnelson@uiuc.edu
> Sent: Thursday, March 30, 2006 6:52 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Smallest observation
> 
> I am trying to create an index for each individual in an
> unbalanced panel. The index should take the value 0 for the
> first time series observation for the individual and 1 for
> all other values.
> 
> My problem is that I can't find the right syntax to replace
> the index with 0 if this is the first time series
> observation. How do I refer to the smallest observation in a
> conditional statement?
> 
> gen s = 1
> bysort indiv: rep s = 0 if year == smallest(year)?
> 
> Thanks.
> 
> Carl Nelson
> 
> *
> *   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/


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