I hope there is someone that will be able to help me. I have been looking at previous FAQ on Statalist but could not find the one that will give me the code I need.

I have two datasets. In the first dataset I have 60 obs of small gold mines in Burkina Faso. I have the longitude and latitude of each mine. It is just a point, not a polygon. So the database looks something like this: (The "objectid" is just each mine numbered and the longitude and latitude is the specific mine's coordinates.)

| objectid longitude latitude |
|--------------------------------------------|
| 1 12.019287 1.3967028 |
| 2 12.471074 .76883174 |
| 3 13.353399 -.29639484 |
| 4 12.411368 -.72431002 |
| 5 12.246743 -.87246019 |

In the second database I use data from the DHS survey from USAID - I have more than 25000 observations of households in Burkina Faso. With variables that describe the household (wealth, if they have electricity, literacy, etc) as well as the longitude and latitude of the village the household is in. It looks something like this:

id longit~e latitude wealth~x litera~y |
|-------------------------------------------------------------------|
| 517 -4.307324 11.18618 richest able to |
| 164 -2.36086 13.205 richer cannot r |
| 200 -5.289879 10.70456 poorest cannot r |
| 349 0.304598 13.81315 poorest cannot r |
| 173 -4.324343 9.669069 richest cannot r |


My question:
I want to create a dummy variable in my second database called vicinity_mine that is 1 if the household's village (longitude and latitude attached to the household) is in the vicinity of a mine and 0 if not. Let's say "vicinity" is defined as within a 5km radius of the mine. I want to use the coordinates of the mines in the first database to create such a database but I am not sure where to start.


I have very little experience with distances and using coordinates on Stata so any help on what code I should use will be very helpful.

Thank you very much.
All the bet,
Nettie