turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- GEODIST Function - Manual calculation

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-20-2017 08:07 PM

Hi All,

Could you please help if there a SAS code to exactly replicate the GEODIST function?

I want to calculate the distance using latitudes and longitudes but it should exactly replicate the outcome of GEODIST function for the same input of latitudes and longitudes.

For ex:

If Distance = geodist(32.5153, -92.1567, 32.53238, -92.07976, 'DM'); is giving 4.6443116482

I want to calculate it manually to get the same value 4.6443116482.

Thanks a lot.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to InnovativeMinds

10-20-2017 05:43 PM

Hi All,

Could you please help if there a SAS code to exactly replicate the GEODIST function?

I want to calculate the distance using latitudes and longitudes but it should exactly replicate the outcome of GEODIST function for the same input of latitudes and longitudes.

Thanks a lot.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to InnovativeMinds

10-20-2017 05:53 PM

Do you mean manual code? ie

( x**2 + y **2 ) ^ 1/2 .....

Because SAS has a GEODIST function so I'm confused....

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

10-20-2017 05:56 PM

Hi, Yes, I'm looking for manual code not the function.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

10-20-2017 06:00 PM

For ex:

If Distance = geodist(32.5153, -92.1567, 32.53238, -92.07976, 'DM'); is giving 4.6443116482

I want to calculate it manually to get the same value 4.6443116482.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to InnovativeMinds

10-20-2017 06:06 PM

Out of curiousity, why?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

10-20-2017 06:11 PM

I need to work and explain non-SAS user how I'm coming up with that (GEODIST) value.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to InnovativeMinds

10-20-2017 08:13 PM

Note that I've merged this into one thread since it's the exact same question.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to InnovativeMinds

10-21-2017 12:17 AM

This might be more difficult than you expect. SAS doesn't use the simple great circle distance formulas that you can find on Wikipedia. They are calculating the distance on some ellipsoid approximating the shape of the Earth. You can look at the reference that they give here.

https://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

10-21-2017 12:27 AM

Before GEODIST() there was a %geodist macro. You can find it via Google, it's relatively close but not exact to the numbers from GEODIST().

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

10-21-2017 07:40 AM

Thanks, PG. Appreciate the information.