Dear All,
I have a general question, though I'm not sure how to phrase it. As such, let me use the following example. Let's say I have panel data, where each panel consists of some static variables and time series ones as well (pretty standard). Furthermore the panel is unbalanced. Now, let's also say that one of these variables, call it 'diff' varies from 13 and 29 between panels but is constant within a given panel. I would like to generate a new variable, call it 'sum' which is a rolling sum of another, time-series variable, call it 'var'. However, and here's the part that I'm curious about, is it possible to set the window of the rolling sum equal to the value of 'diff', which as stated above varies from one panel of the data to another?
I've seen in a post that someone created a rolling, length-7 sum by first creating a cumulative sum and then creating a new variable equal to that cumulative sum less the 6th lag (sum[_n-6]). Is it possible in Stata to insert a variable name in place of "-x"? So it would, for instance, be sum - sum[_-'diff'] or alternatively sum - L'diff'.sum?
I'm curious about this for a current problem I have but also in general, as it would be a powerful tool. Thanks in advance!
I have a general question, though I'm not sure how to phrase it. As such, let me use the following example. Let's say I have panel data, where each panel consists of some static variables and time series ones as well (pretty standard). Furthermore the panel is unbalanced. Now, let's also say that one of these variables, call it 'diff' varies from 13 and 29 between panels but is constant within a given panel. I would like to generate a new variable, call it 'sum' which is a rolling sum of another, time-series variable, call it 'var'. However, and here's the part that I'm curious about, is it possible to set the window of the rolling sum equal to the value of 'diff', which as stated above varies from one panel of the data to another?
I've seen in a post that someone created a rolling, length-7 sum by first creating a cumulative sum and then creating a new variable equal to that cumulative sum less the 6th lag (sum[_n-6]). Is it possible in Stata to insert a variable name in place of "-x"? So it would, for instance, be sum - sum[_-'diff'] or alternatively sum - L'diff'.sum?
I'm curious about this for a current problem I have but also in general, as it would be a powerful tool. Thanks in advance!
Comment