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
How to drop firm-years observations in which CEO turnover occurredHello everyone, I am a new user on Stata and I need some help with the first replication study I am …
Question on Cluster Anlysis Partitioning Around Medoids (PAM) using clpamHello all, How are you? I hope your week is going well! Im conducting a k-medoids cluster analysis…
Count drought years for previous 7 years, by groupI've got a dataset set up roughly like the below. The variable "drought" is equal to 1 if that year …
Leave some imputed variables out of imputation of other variablesI'm working on running mi impute on a data set with an unfortunate structure, where I have: 1) Seve…
Understanding the "normal" function in StataI have z-scores on BMI, I created them using the egen function zanthro() and they look like the belo…
Subscribe to:
Post Comments (Atom)
0 Response to Mark latest observation with unbalanced paneldata
Post a Comment