Hi!
I'm Martina, and I'm using Stata17. I'd like to ask for your help in addressing the following matter.
I have a dataset of investment projects that occurred in a certain country, along with a series of information regarding the country itself (the gdp for the time period 2008-2013). Here are the variables: projectID, projectyear, country, gdp2008, gdp2009, gdp2010, gdp2011, gdp2012, gdp2013. projectID uniquely identifies observations in the dataset (each row is a project), and gdp2008-gdp2013 refer to the gdp of the country stored in the variable country.
Now, I'd like to create a new variable that equals the mean of the gdp for the three years prior the project itself. Put differently: project 1 occured in Italy in 2011 and I want to create a new variable that equals the mean of gdp2008, gdp2009 and gdp2010.
I tried to create a set of new variables for each block of three years (gdp2008_2010, gdp2009_2011 etc.) using rowmean, but for each project I'd like to keep just the one that refers to the three years prior projectyear. How can I do this?
Thank you for your help!
Martina
I'm Martina, and I'm using Stata17. I'd like to ask for your help in addressing the following matter.
I have a dataset of investment projects that occurred in a certain country, along with a series of information regarding the country itself (the gdp for the time period 2008-2013). Here are the variables: projectID, projectyear, country, gdp2008, gdp2009, gdp2010, gdp2011, gdp2012, gdp2013. projectID uniquely identifies observations in the dataset (each row is a project), and gdp2008-gdp2013 refer to the gdp of the country stored in the variable country.
Now, I'd like to create a new variable that equals the mean of the gdp for the three years prior the project itself. Put differently: project 1 occured in Italy in 2011 and I want to create a new variable that equals the mean of gdp2008, gdp2009 and gdp2010.
I tried to create a set of new variables for each block of three years (gdp2008_2010, gdp2009_2011 etc.) using rowmean, but for each project I'd like to keep just the one that refers to the three years prior projectyear. How can I do this?
Thank you for your help!
Martina

Comment