ID | year | open | near_2 | near_3 | competition | exposed |
1 | 2005 | 1 | 1 | 1 | 0 | 0 |
1 | 2006 | 1 | 1 | 1 | 0 | 1 |
1 | 2007 | 1 | 1 | 1 | 0 | 1 |
2 | 2005 | 0 | 1 | 0 | 0 | 0 |
2 | 2006 | 1 | 1 | 0 | 1 | 0 |
2 | 2007 | 1 | 1 | 0 | 0 | 0 |
3 | 2005 | 0 | 0 | 1 | 0 | 0 |
3 | 2006 | 0 | 0 | 1 | 0 | 0 |
3 | 2007 | 1 | 0 | 1 | 1 | 0 |
Im working with a panel data and I want to identify when a grocery store is exposed to competition, meaning when one store is opening less than 3km close to a store that is already opened. My competition variable attains value 1 for when that store is exposing another store for competition. The "exposed" variable is an indicator of which store that is exposed to competition by other stores. Im new to STATA so im having issues with generating my "exposed" variable.
I want to generate a variable "exposed" that attains value 1 for those years when other units are exposing that store for competition, which in my case is when other stores(ID 2 & 3) competition variable attains the value of 1 and and are close to ID=1 which is open the whole period.
Btw. I cannot install any packages on the computer im using STATA on.
Thanks!
0 Response to Replace value in one row based on another variables
Post a Comment