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
Missing Data - Replace Variable Command Issue - Using ds and foreach commandsI am using Stata version 15.1 and I have 47 variables and 1,010 observations in my dataset. I am doi…
Stata's log-likelihood and likelihood ratio test for gamma GLMI'm trying to make sense of the log-likelihood reported by Stata for a glm with family(gamma), which…
Store inverse of mean for dummy variable without recodeI am trying to just get some simple means of indicator variables and store them to create a new data…
jackknifing the wild bootstrap using boottestIn the wild bootstrap, the process for generating many simulated data sets begins by refitting the o…
Positive and Negative DV Values in Panel Data analysis, potential solutionsis it possible to regress a period average of your DV onto annual values of IVs. My DV is Chinese OF…
Subscribe to:
Post Comments (Atom)
0 Response to Sequence variable
Post a Comment