BookmarkSubscribeRSS Feed
timmy555
Calcite | Level 5

I am using by group processing and trying to find the average of a variable I am doing the processing on. So if it was points earned for 5 games with the points being 5,6,7,8,9 How can I find average of these using by group processing? 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

@timmy555 please be more specific than this. Can you show us some sample data? Do you have some code that you have tried already?

ballardw
Super User

BY group processing means that you have one or more variables used to define the group. When you say "points in  a game" then the likely BY variable would be a TEAM identification. So here is a possible example:

 

data example;
   input team $  score;
datalines;
A 15
B 26
A 3
B 18
C 3
C 6
C 27
;
proc sort data=example;
  by team;
run;

proc means data=example mean;
   by team;
   var score;
run;

Please note the data step as way of documenting the data and providing something that you can run to create a data set that be used.

BY groups also usually require sorting by the group variables before any analysis.

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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