BookmarkSubscribeRSS Feed
emma19901
Calcite | Level 5

Hi, I am trying to count categorical variables on the following dataset., I need to count how many players have normal performance on the south team by month., This is an 8,000 observations dataset.

Player

performance

Team                          month

1

High

north                             3

2

normal

south                            7

3

low

north                             5

4

High

north                            9

6

normal

south                           -

7

low

north                           -

8

High

north

2 REPLIES 2
ballardw
Super User

Do you need a data set for further processing (computer use) or a report (people read)?

 

This example code would provide a count all combinations of performance and team as a report.

proc freq data=have;
  tables performance*team / list missing;
run;

You can subset the data with where statement:

 

proc freq data=have;
  where performance='normal' and team='south';
  tables performance*team / list missing;
run;
Ksharp
Super User

proc sql;

select count(distinct player) 

 from have

  group by team,month;

quit;

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