Returns the geodetic distance between two latitude and longitude coordinates.

Category: | Distance |

is a numeric constant, variable, or expression that specifies the coordinate of a given position north or south of the equator. Coordinates that are located north of the equator have positive values; coordinates that are located south of the equator have negative values.

Restriction | If the value is expressed in degrees, it must be between 90 and –90. If the value is expressed in radians, it must be between pi/2 and –pi/2. |

is a numeric constant, variable, or expression that specifies the coordinate of a given position east or west of the prime meridian, which runs through Greenwich, England. Coordinates that are located east of the prime meridian have positive values; coordinates that are located west of the prime meridian have negative values.

Restriction | If the value is expressed in degrees, it must be between 180 and –180. If the value is expressed in radians, it must be between pi and –pi. |

specifies a character constant, variable, or expression that contains any of the following characters:

M | specifies distance in miles. |

K | specifies distance in kilometers. K is the default value for distance. |

D | specifies that input values are expressed in degrees. D is the default for input values. |

R | specifies that input values are expressed in radians. |

The following example shows the geodetic distance in
kilometers between Mobile, AL (latitude 30.68 N, longitude 88.25 W),
and Asheville, NC (latitude 35.43 N, longitude 82.55 W). The program
uses the default K option.

data _null_; distance=geodist(30.68, -88.25, 35.43, -82.55); put 'Distance= ' distance 'kilometers'; run;

The following example uses the M option to compute the geodetic
distance in miles between Mobile, AL (latitude 30.68 N, longitude
88.25 W), and Asheville, NC (latitude 35.43 N, longitude 82.55 W).

data _null_; distance=geodist(30.68, -88.25, 35.43, -82.55, 'M'); put 'Distance = ' distance 'miles'; run;

The following example
uses latitude and longitude values that are expressed in degrees to
compute the geodetic distance between two locations. Both the D and
the M options are specified in the program.

The following example
uses latitude and longitude values that are expressed in radians to
compute the geodetic distance between two locations. The program converts
degrees to radians before executing the GEODIST function. Both the
R and the M options are specified in this program.

data _null_; input lat1 long1 lat2 long2; pi = constant('pi'); lat1 = (pi*lat1)/180; long1 = (pi*long1)/180; lat2 = (pi*lat2)/180; long2 = (pi*long2)/180; Distance = geodist(lat1,long1,lat2,long2,'RM'); put 'Distance= ' Distance 'miles'; datalines; 35.2 -78.1 37.6 -79.8 ; run;

“Direct and Inverse Solutions of Geodesics on
the Ellipsoid with Application of Nested Equations.” 1975. Survey
Review 22: 99–93.

Copyright © SAS Institute Inc. All rights reserved.