[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Smallest observation
bysort indiv (year) : gen byte index = _n != 1
The sorting by individuals doesn't guarantee
year order within panels.
bysort indiv: gen byte index =_n != 1
> 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)?
* For searches and help try: