BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sanchit
Fluorite | Level 6

Hi,

I have a dataset like this:

LatLong
51.39824-0.09366
51.52927-0.04583
51.541820.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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20
Try the min() aggregate function in SQL, or PROC SUMMARY using the outcome oD geodist() as input.
Data never sleeps
Reeza
Super User

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;
Sanchit
Fluorite | Level 6

Thanks a lot Reeza. It worked!

🙂

-Sanchit

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3480 views
  • 3 likes
  • 3 in conversation