BookmarkSubscribeRSS Feed
BCNAV
Quartz | Level 8

This is probably easy, but maybe not. I have data as:

 

origin    destination   distance_km

CYYC   CYUL           100

EGGL   EDDF            200

 

They airport combinations (origin and destination). Many occur and can repeat.

 

 

How could I get output of unique airport combinations with the average km?

 

For example, the output would show for every unique origin/destination pair

 

origin    destination   avg_distance_km

CYYC   CYUL          101.554

EGGL   EDDF           202.678

 

 

thanks

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

How is the value 101.554 calculated?

Reeza
Super User
Did you try PROC MEANS?
Tom
Super User Tom
Super User

Use PROC MEANS (or SUMMARY they are the same proc).  You can either sort the data and use BY statement. Or use a CLASS statement. If you use a class statement you might want to add NWAYS and MISSING option.

BCNAV
Quartz | Level 8

thanks!  I am using

PROC MEANS data=EGTASK.CCDA_BILLABLE NOPRINT NWAY MISSING;
	CLASS depart dest;
	VAR GOA_FLOWN_GC_DISTANCE;
	OUTPUT OUT=EGTASK.CCDA_PAIRS_AVG_KM_TMP MEAN=;
RUN;

and it seems good!

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 4 replies
  • 1538 views
  • 0 likes
  • 4 in conversation