Hello everyone,

Currently, I am trying to generate a variable that indicates me the number of neighbors that are within 1 km and received a treatment. The indicator must be in control observations and treatment observations. So, if the observation is control, it would give me the total number of treated observations within 1 km, the same for the treated observation.

I have tried with the following code:

nearstat latitude longitude, near(latitude longitude) distvar(mydist) ncount(number_treated_HH) dband(0 1) contvar(puretreatment)

where puretreatment = 1 if the observation received the treatment. Nevertheless, I haven't succed. It returns the total number of neighbors within 1 km, regardless if the observation received or not the treatment.

Thank you very much in advance for your help,

Regards

Sara R