Hello together!
I have Panel Data and I would like to create a variable which is the mean over the past 3 years per person.
bysort pid: gen sheep = (var1[_n-1]+var1[_n-2]+var1[_n-3])/3
would do the trick, if it wasn´t for missing values. For example if var1[_n-2] is missing, I´d like to have the mean with the remaining two values.
The "egen mean" function works wonderful with missing values, but I can´t find a way to change it so that is is only for a certain period of time.
For tips I would be very thankful.
Berit
Related Posts with Panel data: mean per person for certain time period
including time dummy variables make all other variables insignificantDear Statalist, I am working on bilateral remittances data over the period 2011-2017 for a set of d…
Reducing estimated residual of our modelGoodmorning! Can someone explain me how to reduce the estimated residual of our model? …
oaxaca_riffDear members, I am trying to estimate productivity/yield gap between men and women using oaxaca_rif.…
Combining multiple loops to write summary statistics to excel efficiently.Hi, I'm trying to produce summary statistics of a variable efficiently as it will have to be done n…
Many points are overlapped, how to better plot the scatter? Code: * Example generated by -dataex-. To install: ssc install dataex clear input float a double b…
Subscribe to:
Post Comments (Atom)
0 Response to Panel data: mean per person for certain time period
Post a Comment