Hello,
I am new to Stata and I have the following problem:
I have data according: year statecode moneyindicator
2003 1005 1
to etc or
2015 0
With some years of data missing.
'Statecode' is a number assigned to a county/state in a country.
In the given dataset, the 'moneyindicator' variable can only be equal to 1 (meaning the state received money) as of 2008 (to 2015), so all data between 2003-2007 for this variable is always equal to 0.
What I need is code that makes 'moneyindicator' belonging to a certain 'statecode' equal to 1 for all the given years between 2003-2015 if 'moneyindicator' equals to 1 in any of the years between 2008-2015 that belong to the same 'statecode'.
So if 'moneyindicator' equals to 1 for statecode i in 2009-2015, I want a new variable that has value equal to 1 for statecode i in 2003-2015.
Thank you!
0 Response to Expanding a variable value based on conditions of other variables
Post a Comment