Dear Statalist-Community,
I am trying to calculate the distance between two datsets using their latitude & longitude locations and the 'nearstat' command.
Following, the used commands are listed:
************************************************** ****************************
use "$data\Prep_Buffer_DHS.dta", clear
append using "$data\All_Location_Insa_nodup.dta", keep(id latitude longitude)
* Sort so that nearstat will run, putting all projects first
gsort -id
* First count how many projects are within 200 km to know how many loops->to run nearstat
foreach dist in 15 25 50 75 100 200 {
nearstat LATNUM LONGNUM, ///
near(latitude longitude) distvar(_1LSLAdist`dist') ///
ncount(numberwithin`dist') dband(0 `dist') favor(speed)
}
drop _1LSLAdist15 _1LSLAdist25 _1LSLAdist50 _1LSLAdist75 _1LSLAdist100 _1LSLAdist200
************************************************** **********************************
When I run the 'nearstat' command, I get the following error message:
'The order for the nearest neighbor cannot be greater than the number of near features.'
Does anyone know how to interpret the error message? I could'nt find a solution yet.
Thank you very much for your support in advance and warm greetings !
Related Posts with Nearstat Error Message
Forming groups by two string variables that are interchangeableDear Statalists, for my research on repeated alliances I am using a dataset in which each observatio…
Adding customized rows to existing observationsHi everyone, I have two clubs (Kibila & GAF 2) in my dataset each having 73 and 75 observations…
descriptive statistics with svyHi Folks, I'm doing a cross-sectional analysis with one wave of a german Panel study. I weighted my…
List all combinations of a set of items sorted by quantityHello everyone! I am currently working with survey data in Stata. The set of items i am working wit…
ordinal regression with interaction term (ordinal and binary variable)How can I interpret this outcome and especially the interaction term? repression (0= minamal, 1= mo…
Subscribe to:
Post Comments (Atom)
0 Response to Nearstat Error Message
Post a Comment