[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: creating a "years since event" variable in panel data
Note that there is an
FAQ . . . . . . . . . . . . . . . First and last occurrences in panel data
12/05 How can I identify first and last occurrences
systematically in panel data?
In Christer's set-up, the first OBSYEAR in which EVENT first occurred by
egen FIRSTYEAR = min(cond(EVENT == 1, OBSYEAR, .)), by(ID)
after which you can subtract. The trick here is realising that many
-egen- functions will accept _expressions_ and not just variable names.
FIRSTYEAR will, naturally, be missing if the EVENT never occurred
to any ID.
I'd echo Austin in also plugging -tsspell- from SSC.
> I have a annual panel data set (1 obs per year), where ID
> identifies the
> person and the variable OBSYEAR the year of observation
> (1995=1, 1996=2,
> ..., 2002=7).
> The variable TIME is the time dimension, ranging from 0 to 7.
> The variable EVENT is a dymmy (1=event happened during the
> year in question;
> 0=event did not happen during the year in question).
> Q: How do I create the variable NUMBER OF YEARS SINCE (A
> POSSIBLE) CHANGE
> FROM 0 to 1 on EVENT?
* For searches and help try: