Dear Statalisters
I have shapefile containing information about the geographic coordinates of all the districts in Pakistan. I am required to have a variable of the distance between a border district and the rest of all the districts. I am using STATA 15's 'spdistance' command to calculate it. As the syntax for 'spdistance' returns the distance between two district IDs whereas I want to calculate the distance between 93 districts. Is there any way I can do it in a loop? I am writing the codes here as I am not sure how to use 'dataex' with shapefile.
capture drop distance
gen distance=.
local id 20 54 94 95 99 101
spdistance `id' 96 (* where 96 is the id for border district which will remain fixed)
replace distance=r(distance) if distt_id==`id'
however, this code returns an error i.e
94 95 99 101 96 found where nothing expected
r(198);
Related Posts with calculating distance in a loop using 'spdistance' in STATA 15
xtabond2: Hansen testGood day all, I'm running a dynamic panel regression with results shown below. I'm wondering if my …
Creating Gini Coefficients from Categorical Income Data in 2000 US CensusHey everyone, This is my first post to Statalist. Please let me know if there is anything missing i…
Show SD-within statistics from panel data via outreg2 descriptive tableDear Statalist, For my Masters I need to replicate a paper using Stata. I have managed to successfu…
How to plot the below graphs after quantile regression?Please could anyone tell how to plots the same graphs after quantile regression? I have tried to plo…
Wilcoxon matched-pair sign-rank test -signrank- with a grouping variable ( by(groupvar) )Hi! I'm conducting a study in which I have 3 controls per case, matched on age, cancer stage and ca…
Subscribe to:
Post Comments (Atom)
0 Response to calculating distance in a loop using 'spdistance' in STATA 15
Post a Comment