%macro latlond (lat1,long1,lat2,long2); %*Use the Haversine formula to calculate dist b/w two points on earth Lat/Longs are in decimal degrees, Same as geodist macro downloaded from sashelp.com, written by D. Ward THE CONSTANT 7921.6623 IS 2*RADIUS OF EARTH IN MILES *; %let pi180=0.0174532925199433; /** USED TO CONVERT DEG TO RAD **/ 7921.6623*arsin(min(1,sqrt((sin((&pi180*&lat2-&pi180*&lat1)/2))**2+ cos(&pi180*&lat1)*cos(&pi180*&lat2)*(sin((&pi180*&long2-&pi180*&long1)/2))**2))) %mend; /* Example: data mydata; set myotherdata; dist=%latlond(mylat1,mylong1,mylat2,mylong2); run; */