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
Dropping observation under conditionsDear expers, my data: Code: * Example generated by -dataex-. To install: ssc install dataex clear …
density plothello. I am not familiar with the density plot and I have a simple question. I have information abou…
Likelihood ratio omnibus test of significance & multiple comparisonsHi there, I have a data set which includes: 5 polygenic scores for different mental illnesses and a…
Drop variable if varlabel contains certain expressionHey Statalisters, I am trying to drop all variables that have the expression "Domestic Currency" in…
CFA correlation error loading issueHi guys, What am i doing wrong ? I am working on CFA and I trying to correlate my error loading but…
Subscribe to:
Post Comments (Atom)
0 Response to Expanding a variable value based on conditions of other variables
Post a Comment