Descriptive Statistics in SAS PROC TABULATE
Descriptive Statistics in SAS, PROC TABULATE
provides a convenient way to display descriptive statistics for one or more variables in a clear tabular format.
Descriptive Statistics in SAS
Below are examples using a dataset that includes the total points scored by 12 different basketball players.
Creating the Dataset
First, let’s define the dataset that contains the relevant information:
/* Create dataset */
data my_data;
input team $ position $ points;
datalines;
A Guard 15
A Guard 12
A Guard 29
A Forward 13
A Forward 9
A Forward 16
B Guard 25
B Guard 20
C Guard 34
C Forward 19
C Forward 3
C Forward 8
;
run;
/* View the dataset */
proc print data=my_data;
run;
Example 1: PROC TABULATE with One Variable
To calculate and display descriptive statistics for the points
variable, use the following code:

/* Create table to display descriptive statistics for points variable */
proc tabulate data=my_data;
var points;
table points * (N Min Q1 Median Mean Q3 Max);
run;
Explanation of the Statistics:
- N: Total number of observations
- Min: Minimum value
- Q1: First quartile (25th percentile)
- Median: Median value
- Mean: Average value
- Q3: Third quartile (75th percentile)
- Max: Maximum value
From the output, you would observe:
- Total observations: 12
- Minimum points: 3
- 25th percentile (Q1): 10.5
- Median points: 15.5
- Mean points: 16.92
- 75th percentile (Q3): 22.5
- Maximum points: 34
These statistics provide a comprehensive understanding of the distribution of points.
Example 2: PROC TABULATE with Two Variables
To show descriptive statistics for the points
variable, categorized by the team
variable, use the following code:
/* Create table to display descriptive statistics for points, grouped by team */
proc tabulate data=my_data;
class team;
var points;
table team, points * (N Min Q1 Median Mean Q3 Max);
run;
The resulting table breaks down the descriptive statistics for points
for each of the three teams. For instance:
- Team A: 6 observations, minimum points: 9, 25th percentile: 12, median: 14, etc.
Example 3: PROC TABULATE with Three Variables
To calculate descriptive statistics for points
, grouped by both team
and position
, utilize the following code:
/* Create table to show descriptive statistics for points, grouped by team and position */
proc tabulate data=my_data;
class team position;
var points;
table team, position * points * (N Min Q1 Median Mean Q3 Max);
run;
This table displays descriptive statistics for points
, segmented by both the team
and position
variables. It’s important to note that some cells may be empty, such as for Team B at the Forward position, indicating that there were no players in that category.
Conclusion
With PROC TABULATE
, you can efficiently calculate and present descriptive statistics for one or more variables in a structured tabular format, providing valuable insights into your dataset.