Hi,
I have a panel data set, where individuals are identified by "id" and time periods are identified by "date". For each id-date observation, there is a numeric variable "var".
What I want to do is to create a rolling-window variable "ms", which sums var over the prior 10 dates for each id. For some id-date observations, there might be less than 10 dates available - say only 5 since the first date for that id - then ms should be the sum of var over these 5 observations.
How can I achieve this in a simple way?
I have a panel data set, where individuals are identified by "id" and time periods are identified by "date". For each id-date observation, there is a numeric variable "var".
What I want to do is to create a rolling-window variable "ms", which sums var over the prior 10 dates for each id. For some id-date observations, there might be less than 10 dates available - say only 5 since the first date for that id - then ms should be the sum of var over these 5 observations.
How can I achieve this in a simple way?
Comment