I would like to create seq_temp variable which is a count from 1,2,3, of temp (within each personid) where episode==1. See below what I would like to see in seq_temp
input byte personid float episode float temp float seq_temp
1 1 1 1
1 0 1 .
1 1 1 2
1 1 0 .
1 0 1 .
2 0 1 .
2 1 0 .
2 1 1 1
When I try this below I seem to get a conflict where STATA says "the data is not sorted":
by personid temp episode: gen seq_temp=_n if temp==1 & episode==1
Related Posts with Sequence variable
Instrumental variable estimation for panel data in case of heteroskedasticity and weak instrumentsI have an unbalanced panel dataset (N=504, T=3) and I am trying to run instrumental variable regress…
xtabond2Dear all, I am running some dynamic panel data with xtabond2, and often the coefficients of the lagg…
STATA SE 13, how to get r square after mi estimateDear STATA users, is there a way to obtain R square (model fit statistics) after conducting mice? I…
linear mixed model accounting for correlated observationsHi I am looking for some advice regarding the appropriate code to use to assess agreement between 5 …
over-identify testwhen i run the command (estat overid) i got the following error message (no overidentifying restrict…
Subscribe to:
Post Comments (Atom)
0 Response to Sequence variable
Post a Comment