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
How can I check if two string variables contain any same elements?Hi all, I have a question about comparing two string variables. I wanted to compare the values of t…
Coding the competitive(close) election in U.S. state legistlation electionsIt is my first time writing a post in the forum, so I am not sure I can use dataex. As a result, I p…
psmatch2 and teffects psmatchI have a question, how can I get the pscore delivered by psmatch2 command automatically, but using t…
mixed: How do I retrieve the intercept-slope correlation?Hi I am fitting a model like this: Code: webuse nlswork, clear mixed ln_w tenure || id: tenure, …
How to create a dummy age for 165 people for 20 yearsDear All I wanted to ask how we can create a dummy age and date of appointment for 170 people for 2…
Subscribe to:
Post Comments (Atom)
0 Response to Generating Variable Based On Several Conditions
Post a Comment