Dear all,
I have two datasets in which for every observation there are two variables, lat and long, providing the geographic coordinates to that observation. In dataset A I have a panel data of firms and in dataset B I have the coordinates for each regulator field offices in each state. The two datasets look like as follows:
Dataset A (firms)
Dataset B (field office)
What I need is to find the closes regulator field office for each firm that is located in the same state for the regulatory agency that is in charge of the firm
So far I am using the command geonear as follows:
geonear _id lat long using "fieldoffice.dta", n(_idfo latitude_fo longitude_fo)
However, I am not sure whether I can use conditioning using something like "if" (i.e. if id state_A==state_B and regulator_agency_A==regulator_agency_B then find the closes field office for each firm).
I am using State 14.2
Thank you a lot in advance.
Best regards,
I have two datasets in which for every observation there are two variables, lat and long, providing the geographic coordinates to that observation. In dataset A I have a panel data of firms and in dataset B I have the coordinates for each regulator field offices in each state. The two datasets look like as follows:
Dataset A (firms)
firm_id | year | state_A | regulator_agency_A | lat | long | _id |
1 | 1 | TX | SEC | 32.3755 | -86.3031 | 1 |
1 | 2 | TX | SEC | 32.3755 | -86.3031 | 2 |
1 | 3 | TX | SEC | 32.3755 | -86.3031 | 3 |
2 | 1 | NY | SEC | 37.7912 | -122.397 | 4 |
2 | 2 | NY | SEC | 37.7912 | -122.397 | 5 |
2 | 3 | NY | SEC | 37.7912 | -122.397 | 6 |
3 | 1 | TX | FDIC | 33.4127 | -86.7146 | 7 |
3 | 2 | TX | FDIC | 33.4127 | -86.7146 | 8 |
3 | 3 | TX | FDIC | 33.4127 | -86.7146 | 9 |
state_B | regulator_agency_B | latitude_fo | longitude_fo | _idfo |
TX | SEC | 32.3755 | -86.3031 | 1 |
TX | SEC | 32.8767 | -86.5054 | 2 |
AR | SEC | 33.4127 | -86.7146 | 3 |
NY | SEC | 33.47 | -86.8298 | 4 |
NY | FDIC | 34.7496 | -92.399 | 5 |
TX | FDIC | 35.834 | -90.7048 | 6 |
VI | FDIC | 36.1793 | -94.1902 | 7 |
So far I am using the command geonear as follows:
geonear _id lat long using "fieldoffice.dta", n(_idfo latitude_fo longitude_fo)
However, I am not sure whether I can use conditioning using something like "if" (i.e. if id state_A==state_B and regulator_agency_A==regulator_agency_B then find the closes field office for each firm).
I am using State 14.2
Thank you a lot in advance.
Best regards,
Comment