## GEODIST Function - Manual calculation

Occasional Contributor
Posts: 13

# GEODIST Function - Manual calculation

Hi All,

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.

Occasional Contributor
Posts: 13

## GEODIST function calculation

Hi All,

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.

Super User
Posts: 23,339

## Re: GEODIST function calculation

Do you mean manual code? ie

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

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

Occasional Contributor
Posts: 13

## Re: GEODIST function calculation

Hi, Yes, I'm looking for manual code not the function.
Occasional Contributor
Posts: 13

## Re: GEODIST function calculation

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.

Super User
Posts: 23,339

## Re: GEODIST function calculation

Out of curiousity, why?

Occasional Contributor
Posts: 13

## Re: GEODIST function calculation

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

Super User
Posts: 23,339

## Re: GEODIST function calculation

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

Posts: 5,482

## Re: GEODIST Function - Manual calculation

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
Super User
Posts: 23,339

## Re: GEODIST Function - Manual calculation

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().

Occasional Contributor
Posts: 13

## Re: GEODIST Function - Manual calculation

Thanks, PG. Appreciate the information.

Discussion stats
• 10 replies
• 204 views
• 2 likes
• 3 in conversation