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?

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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