Table of Contents

Performing a Mann-Whitney U Test in SAS is a relatively straightforward process. The most important step is to set up your data prior to running the test; this involves organizing the data into two separate groups, and setting up a SAS data set. Once this is done, you can use the SAS PROC NPAR1WAY procedure to run the Mann-Whitney U Test. This procedure will generate a U statistic, a z-score, and a p-value that can be used to determine whether the two groups are significantly different from each other.

A **Mann-Whitney U test** (sometimes called the Wilcoxon rank-sum test) is used to compare the differences between two samples when the sample distributions are not normally distributed and the sample sizes are small (n <30).

It is considered to be the nonparametric equivalent to the .

This tutorial explains how to perform a Mann-Whitney U test in SAS.

**Example: Mann-Whitney U Test in SAS**

Suppose researchers want to know if a fuel treatment leads to a change in the average mpg of a car. To test this, they conduct an experiment in which they measure the mpg of 12 cars with the fuel treatment and 12 cars without it.

The results are shown below:

Because the sample sizes are small and they suspect that the sample distributions are not , they decide to perform a Mann-Whitney U test to determine if there is a statistically significant difference in mpg between the two groups.

Use the following steps to perform a Mann-Whitney U test in SAS.

**Step 1: Create the Dataset**

First, we’ll use the following code to create the dataset in SAS:

/*create dataset*/ data mpg_data; input group $ mpg; datalines; treated 24 treated 25 treated 21 treated 22 treated 23 treated 18 treated 17 treated 28 treated 24 treated 27 treated 21 treated 23 untreated 20 untreated 23 untreated 21 untreated 25 untreated 18 untreated 17 untreated 18 untreated 24 untreated 20 untreated 24 untreated 23 untreated 19 ; run;

**Step 2: Perform the Mann Whitney U Test**

Next, we’ll use **proc npar1way** to perform the Mann Whitney U test:

/*perform Mann Whitney U test*/ proc npar1way data=mpg_data wilcoxon; class group; var mpg; run;

From the Wilcoxon Two-Sample Test table, we see that the two-sided p-value of the test turns out to be **0.2114**.

**H**: The two populations have the same median._{0}**H**: The two populations have different medians._{A}

Since the p-value of the test (**.2114**) is not less than .05, we fail to reject the null hypothesis.

This means we do not have sufficient evidence to say that the mpg is different between the cars that receive fuel treatment and those that don’t.

SAS also provides boxplots to visualize the distribution of mpg values for each group:

From the plot we can see the cars that received the fuel treatment tended to have higher mpg values, but from the results of the Mann Whitney U test we know that the differences between the two groups was not statistically significant.

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