Dear Statalist,
I have a dataset with patient IDs and lat/lon data about their residence postal code. I have a second data set with clinic departments and their lat/lon data and the number of hospital beds for each department.

I want to generate a variable in the patient data set that gives me the number of hospital beds within a certain distance.

I looked at this solution via genoear https://www.statalist.org/forums/for...using-lat-long and it works perfectly to generate the number of departments in a radius (which I'm also interested in) but how can I sum the hospital bed numbers instead of counting the number of departments?