Dear board members,
the simplified structure of my data is as follows: i have a panel data set on the municipal level with several variables over the course of nine years. Each municipality has a specific code and is also part of a geographic region with another specific code. Now, I would like to create a new dummy variable for each municipality and year that takes the value of one if the "original variable" is 1 in either n or n-1 in any municipality that is part of the same geographic region, but not in the municipality itself.
To illustrate even further, say a municipality Alpha is part of a county Beta that consists of 15 municipalities overall. I have observations whether a significant change has happened in each of these municipalities in every year (the "original variable" takes 1 in this case). Now, for any given year, the new variable should take the value one for Alpha if the significant change has occured within the last two years in any municipality in Beta, and, in case there were only one or two changes in the 30 observations of the last two years, that change must not have happened in Alpha. I hope this makes it relatively clear.
Any ideas how to achieve this? Your help is appreciated.
Kind regards,
Will
Related Posts with Generating Variable Based On Several Conditions
spmap command produces only a fraction of the intended mapHello! I'm trying to draw a map that shows proportion of households in a state that report a migrant…
Unbalanced Panel - Selection Bias due to unequal time periods onlyHi everyone, I have an unbalanced panel data per Stata as seen here: Code: . //Setting panel var…
Variable information in table notes using estout/esttabHi, I am trying to format a series of regression tables with estout/esttab. My regressions all have…
Help needed in exporting output from the groups commandI am trying to generate frequencies for a certain variable and the groups command from the package '…
bctobit LM testgood evening stata users i am using tobit model and after running the model to test for normality an…
Subscribe to:
Post Comments (Atom)
0 Response to Generating Variable Based On Several Conditions
Post a Comment