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!
Related Posts with Expanding a variable value based on conditions of other variables
Moran's I and spatial weights matrixHello everybody, I wish to compute the Moran's I statistic and I'm following the code written by Pi…
Statistics tableHi, I have a dataset for 12 countries, and looking to generate a table similar to the attached one. …
ginidesc questionsHi all, I am new to this forum and a very new STATA user so any help or suggestions at all is appre…
Plotting output from stpm2.I'm looking to plot differences in survival among patients in different treatment groups. The KM cur…
expand data at the beginning of the panelHi all, I try to create new missing values in a dataset, in order to obtain the same time period fo…
Subscribe to:
Post Comments (Atom)
0 Response to Expanding a variable value based on conditions of other variables
Post a Comment