Hi,
I have a dataset like this:
| Lat | Long |
| 51.39824 | -0.09366 |
| 51.52927 | -0.04583 |
| 51.54182 | 0.038004 |
| 51.41895 | -0.30561 |
| 51.59302 | -0.06998 |
| 51.60087 | -0.19474 |
| 51.55101 | -0.13727 |
| 51.50019 | -0.07006 |
| 51.48329 | -0.02586 |
I need to determine the minimum distance between these set of coordinates. I know about a function geodist() to determine distance between 2 coordinates, but not sure how to loop over through this set from the table.
Greatly appreciate your help.
Thanks!
You have to check distance between all unfortunately.
Use a Cartesian join in SQL and the GEODIST() function.
Heres a sketch of the code.
Proc SQL;
Create table dist as
Select a.*,
B.lat as lat2,
B.long as long2,
Geodist(....) as distance
From have as a
CROSS JOIN
have as b
Order by distance;
Quit;
You have to check distance between all unfortunately.
Use a Cartesian join in SQL and the GEODIST() function.
Heres a sketch of the code.
Proc SQL;
Create table dist as
Select a.*,
B.lat as lat2,
B.long as long2,
Geodist(....) as distance
From have as a
CROSS JOIN
have as b
Order by distance;
Quit;
Thanks a lot Reeza. It worked!
🙂
-Sanchit
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.