Online File

### Chapter 88 Program Global Distances

```* Convert coordinates to degrees N and degrees E;
data cities (keep=city lati long);
infile cities;
input city \$char20. lati_d 2. +1 lati_m 2. +1 lati_ns \$char1.
+1 long_d 3. +1 long_m 2. +1 long_ew \$char1.;
lati = lati_d + lati_m/60;
if lati_ns = 'S' then lati = -lati;
long = long_d + long_m/60;
if long_ew = 'W' then long = -long;
run;
title 'Distances Between Cities';

data _null_;
retain diameter 12741; * Approximate earth diameter (km);
retain r .017453292; * Factor to convert degrees to radians;
file print column=column;
if _n_ = nobs then stop;
set cities (rename=(city=city1 lati=lati1 long=long1));
put / 'FROM ' city1 'TO:' +3 @;
do point = _n_ + 1 to nobs;
set cities (rename=(city=city2 lati=lati2 long=long2))
point=point nobs=nobs;
distance = diameter*arsin(sqrt(
(1 - cos(lati1*r)*cos(lati2*r)*cos((long1 - long2)*r)
- sin(lati1*r)*sin(lati2*r))*.5));
if column > 60 - length(city2) then put / @2 @;
put city2 distance : comma7. +2 @;
end;
run;
```