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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 414 views
  • 0 likes
  • 3 in conversation