Stata 14.0 SE on Mac - Data contais 90,000 obervations
Hi. I am using panel data on US counties (and States) and Medical Marijuana Laws. I am trying to create a count variable which increases by 1 in one state, when a dummy variable is activated in any of the bordering states. This would mean that the count variable would increase by 1 any time a neighbouring state dummy is activated, and decreases by one any time the neighbour dummy is deactivated.
Below, s_id is the stae indicator - with multiple counties per state (although the example below only shows one county per state); fips is the unique county code; c_id is the county within state code, MML is an indicator = 1 if state i has introduced a medical marijuana law in year t.
The Neighbour_MML variable is what I am trying to create. If we assume that s_id 1 is neighboured by s_id's 3 and 4; s_id 2 has no nieghbours; s_id 3 neighbours s_id 4; s_id 4 neighbour s_id's 3 and 5; and s_id 5 only neighbour s_id 4:
With this neighbour pairing combination the Neighbour_MML count variable would look as it does below:
I have all the state pairing but need some assistance in understaing how I can generate the Neighbour_MML count variable for all states based on all pairings?
Any help greatly appreciated,
Thanks,
Mike
Hi. I am using panel data on US counties (and States) and Medical Marijuana Laws. I am trying to create a count variable which increases by 1 in one state, when a dummy variable is activated in any of the bordering states. This would mean that the count variable would increase by 1 any time a neighbouring state dummy is activated, and decreases by one any time the neighbour dummy is deactivated.
Below, s_id is the stae indicator - with multiple counties per state (although the example below only shows one county per state); fips is the unique county code; c_id is the county within state code, MML is an indicator = 1 if state i has introduced a medical marijuana law in year t.
The Neighbour_MML variable is what I am trying to create. If we assume that s_id 1 is neighboured by s_id's 3 and 4; s_id 2 has no nieghbours; s_id 3 neighbours s_id 4; s_id 4 neighbour s_id's 3 and 5; and s_id 5 only neighbour s_id 4:
Dependent | Neighbour |
1 | 3 |
1 | 4 |
3 | 1 |
4 | 1 |
4 | 5 |
5 | 4 |
year | fips | c_id | s_id | MML | Neighbour_MML |
1990 | 1001 | 1 | 1 | 0 | 0 |
1991 | 1001 | 1 | 1 | 0 | 0 |
1992 | 1001 | 1 | 1 | 1 | 1 |
1993 | 1001 | 1 | 1 | 1 | 2 |
1994 | 1001 | 1 | 1 | 1 | 2 |
1990 | 2001 | 1 | 2 | 0 | 0 |
1991 | 2001 | 1 | 2 | 0 | 0 |
1992 | 2001 | 1 | 2 | 0 | 0 |
1993 | 2001 | 1 | 2 | 1 | 0 |
1994 | 2001 | 1 | 2 | 1 | 0 |
1990 | 3001 | 1 | 3 | 0 | 0 |
1991 | 3001 | 1 | 3 | 0 | 0 |
1992 | 3001 | 1 | 3 | 0 | 1 |
1993 | 3001 | 1 | 3 | 1 | 1 |
1994 | 3001 | 1 | 3 | 1 | 1 |
1990 | 4001 | 1 | 4 | 0 | 0 |
1991 | 4001 | 1 | 4 | 0 | 0 |
1992 | 4001 | 1 | 4 | 1 | 0 |
1993 | 4001 | 1 | 4 | 1 | 1 |
1994 | 4001 | 1 | 4 | 1 | 2 |
1990 | 5001 | 1 | 5 | 0 | 0 |
1991 | 5001 | 1 | 5 | 0 | 0 |
1992 | 5001 | 1 | 5 | 0 | 1 |
1993 | 5001 | 1 | 5 | 0 | 1 |
1994 | 5001 | 1 | 5 | 1 | 1 |
Any help greatly appreciated,
Thanks,
Mike
Comment