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