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
Using joinby to combine monthly and yearly panel datasetsHi everybody I have a quick (maby redundant) question about joinby. I have many different panel dat…
Trajectory analysis - keep registry_HbA1c if date_of_HbA1c_test > 1 year after baseline_HbA1c for each ID_numberDear Stata experts, I am really stuck. In my data set, I have variables for the participant's ID nu…
Problem with weight use and specific commandsDear Statalists, I am aware that I am creating an unconvential and unusual post, and apologize in a…
Omitted Interactions in Negative Binomial Panel RegressionHello, I ran into some trouble when introducing interaction effects in my model. To quickly explain…
MatchingDear all, I am getting new with matching firms. The objective of my analysis is to perform a Diffin…
Subscribe to:
Post Comments (Atom)
0 Response to Sequence variable
Post a Comment