I want to mark the latest observation in an unbalanced dataset with panel data
Timevaribel: t (varies som 0 to 17)
person id: id
The program code I use now:
bysort id t: generate last_obs = sum(t==17)==1 & sum(t[n-1]==2)==0
But the problem is that it only marks the persons with a time variable = 17 year and it does not mark the persons with less observations that 17
So how do I generate a variable that marks the latest observation no matter how long the time variabel is?
Related Posts with Mark latest observation with unbalanced paneldata
dropping observations with specific values in two different variablesDear Statalisters, I am currently analysing an employer survey where each observation is an employi…
Loop fails to find local macroHi there, I have an issue with one local macro within a fovalues loop. The main purpose of this co…
import .json data in stataHello everybody, I have to get the data from a .json file in stata. I have been using the following…
xtline time rangeCurrently I am running into what I think should be an easy to solve problem but haven't found a solu…
Interpreting negative binomial coefficient with log IVHello, I'm having a hard time trying to interpret the results of a negative binomial regression (xt…
Subscribe to:
Post Comments (Atom)
0 Response to Mark latest observation with unbalanced paneldata
Post a Comment