How do I calculate descriptive statistics in SAS?

To calculate descriptive statistics in SAS, you can use the PROC MEANS procedure to generate descriptive statistics such as the mean, median, maximum and minimum values, and the standard deviation of your data set. You can also create a frequency table or summary statistics table. Additionally, you can use the PROC UNIVARIATE procedure to generate a variety of descriptive statistics for a single variable.


Descriptive statistics are values that describe a dataset.

They help us gain an understanding of where of the dataset is located along with how the values are in the dataset.

There are two common ways to calculate descriptive statistics for variables in SAS:

1. Use PROC MEANS to Calculate Summary Statistics

2. Use PROC UNIVARIATE to Calculate Detailed Descriptive Statistics

The following examples show how to use each method in practice with the following dataset in SAS:

/*create dataset*/
data my_data;
    input team $ points assists;
    datalines;
A 10 2
A 17 5
A 17 6
A 18 3
A 15 0
B 10 2
B 14 5
B 13 4
B 29 0
B 25 2
C 12 1
C 30 1
C 34 3
C 12 4
C 11 7
;
run;

/*view dataset*/
proc print data=my_data;

Example 1. Use PROC MEANS to Calculate Summary Statistics

The following code shows how to use PROC MEANS to calculate summary statistics for the points variable in the dataset:

/*calculate summary statistics for points variable*/
proc means data=my_data;
    var points;
run;

descriptive statistics in SAS using PROC MEANS

The PROC MEANS procedure calculates the following descriptive statistics:

  • N: The total number of observations
  • Mean: The mean value of points
  • Std Dev: The standard deviation of points
  • Minimum: The minimum value of points
  • Maximum: The maximum value of points

Also note that you can use the class statement to calculate descriptive statistics for one variable, grouped by another variable.

For example, we can use the following code to calculate summary statistics for the points variable, grouped by the team variable:

/*calculate summary statistics for points, grouped by team*/
proc means data=my_data;
    class team;
    var points;
run;

The output displays the summary statistics for the points variable, grouped by each of the unique team values.

Example 2. Use PROC UNIVARIATE to Calculate Detailed Descriptive Statistics

The following code shows how to use PROC UNIVARIATE to calculate detailed descriptive statistics for the points variable:

/*calculate detailed descriptive statistics for points variable*/
proc univariate data=my_data;
    var points;
run;

The PROC UNIVARIATE procedure calculates detailed descriptive statistics for the points variable including the mean, median, mode, standard deviation, variance, range, interquartile range, and more.

We can also use the class statement to calculate these detailed descriptive statistics for the points variable, grouped by the team variable:

/*calculate detailed descriptive statistics for points, grouped by team*/
proc univariate data=my_data;
    class team;
    var points;
run;

This will produce three groups of output tables that display detailed descriptive statistics for the points variable, grouped by each of the unique team values.

The following tutorials explain how to perform other common tasks in SAS:

x