BookmarkSubscribeRSS Feed
BCNAV
Quartz | Level 8

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

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

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');

 

ballardw
Super User

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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 658 views
  • 0 likes
  • 3 in conversation