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
Fixed EffectsDear Statalists, I have a question regarding fixed effects models: if I am trying to measure the im…
Mixed regression contrastsDear Listers, Using -contrast- after the -mixed- command allows you to test the main and interactio…
do we have user-command like reghdfe for logit or probit models?Thanks for your infomation! …
Collapse by partial groupI have a big dataset of county level demographics "County Statename Year Agegroup" where agegroup …
Add a reference lineHi, Please, could someone share with me an example of code with "TRAJ" command, specifically the po…
Subscribe to:
Post Comments (Atom)
0 Response to Sequence variable
Post a Comment