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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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