Suppose I know the Lat and Long of an origin and destination airport. I then want to find the main direction of flight.
Example:
EIDW DUBLIN INTERNATIONAL
Lat: 53.4213888889 Long: -6.2700000000
TO:
CYYZ LESTER B. PEARSON INTL
Lat: 43.6767190556 Long: -79.6306582222
In this case I would like to return West. The reverse flight from CYYZ to EIDW would return East
Not sure SAS can do this or not. The preference would be only returning North, East, South, West
Thanks for any ideas
Something like this (untested, I may have my tests confused)?
LAT_DIFF = LAT_DEST - LAT_ORIG;
LON_DIFF = LON_DEST - LON_ORIG;
if LAT_DIFF<0 & LON_DIFF<0 then DIRECTION = ifc(abs(LAT_DIFF) > abs(LON_DIFF), 'S', 'E');
if LAT_DIFF>0 & LON_DIFF<0 then DIRECTION = ifc(abs(LAT_DIFF) > abs(LON_DIFF), 'N', 'E');
if LAT_DIFF>0 & LON_DIFF>0 then DIRECTION = ifc(abs(LAT_DIFF) > abs(LON_DIFF), 'N', 'W');
if LAT_DIFF<0 & LON_DIFF>0 then DIRECTION = ifc(abs(LAT_DIFF) > abs(LON_DIFF), 'S', 'W');
Spherical trigonometry is not my strong point but what is going to be your rules for determining E/W over N/S if the compass angle were to be something like 45 degrees?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: