You can use **PROC MEANS** to calculate summary statistics for variables in SAS.

By default, **PROC MEANS** does not display the interquartile range (IQR) as one of the summary statistics but you can use the **QRANGE** statement to include the IQR in the output:

proc means data=my_data N Mean QRANGE Std Min Max; var points; run;

This particular example calculates the total number of observations, mean, interquartile range, standard deviation, minimum and maximum value for a variable called **points**.

The following example shows how to use this syntax in practice.

**Example: Display IQR in PROC MEANS in SAS**

Suppose we have the following dataset in SAS that contains information about various basketball players:

/*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;

Suppose we 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;

By default, **PROC MEANS** 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

Notice that the IQR is not included in the output.

We can use the following syntax to include the IQR in the output:

/*calculate summary statistics for points and include IQR*/ proc means data=my_data N Mean QRANGE Std Min Max; var points; run;

Notice that the output now includes the interquartile range value for the **points** variable.

We can see that the IQR for the **points** variable turns out to be **13**.

Recall that the IQR represents the difference between the 75th percentile and the 25th percentile for a given variable.

If you’d like to see the values for these percentiles, you can include **P25** and **P75** in the **PROC MEANS** procedure:

/*calculate summary statistics for points and include IQR*/ proc means data=my_data N Mean P25 P75 QRANGE Std Min Max; var points; run;

The output now includes the 25th percentile, the 75th percentile, and the interquartile range for the **points** variable.

**Additional Resources**

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

How to Calculate Descriptive Statistics in SAS

How to Create Frequency Tables in SAS

How to Calculate Percentiles in SAS

How to Create Pivot Tables in SAS