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
Dot plot for two categorical variablesHello, I have the following dataset: clear input str1 item year1 year2 year3 year4 year5 "A" 1 0 0 …
Interpreting values on the Y-axis in hazard functions (Survival Analysis)Hi All. The Y-axis on a survivor function is straightforward to interpret as it is denoted by 1 and…
Multiple interaction terms in panel data modelDear Statalist, First post here! I am working with a panel of exports from Spain to 170 countries.…
Code for counting ID within a variableHi all, I have a variable inc_chng which calculates the changes in the income variable from year to…
Truncating long variable namesHi, Some of the variables in my dataset are too long, and trying to rename them returns an error mes…
Subscribe to:
Post Comments (Atom)
0 Response to Mark latest observation with unbalanced paneldata
Post a Comment