BookmarkSubscribeRSS Feed
InnovativeMinds
Fluorite | Level 6

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.

10 REPLIES 10
InnovativeMinds
Fluorite | Level 6

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.

 

Reeza
Super User

Do you mean manual code? ie 

 

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

 

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

InnovativeMinds
Fluorite | Level 6
Hi, Yes, I'm looking for manual code not the function.
InnovativeMinds
Fluorite | Level 6

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.

 

Reeza
Super User

Out of curiousity, why?

InnovativeMinds
Fluorite | Level 6

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

Reeza
Super User

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

PGStats
Opal | Level 21

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
Reeza
Super User

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

 

 

 

 

InnovativeMinds
Fluorite | Level 6

Thanks, PG. Appreciate the information.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 10 replies
  • 1201 views
  • 2 likes
  • 3 in conversation