turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Compare two medians

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-27-2012 11:21 AM

Is there a test in SAS that compares two medians? I am looking for the equivalent of PROC TTEST, but with medians instead of means.

Thanks.

--

Paige Miller

Paige Miller

Accepted Solutions

Solution

07-06-2017
08:55 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

11-27-2012 03:23 PM

I'm not an expert, but I believe that the Mann-Whitney (aka, Wilcoxon-Mann-Whitney or just Wilcoxon) test is generally used as an alternative to a *t *test when the data are not normally distributed. The Mann-Whitney test is commonly regarded as a test of population medians, but this is technically only true if the two populations have the same shape and one is a "translation" (or shift) of the other. If the populations have different scales and shape, the M-W test will detect that as well, which tends to muddy the results.

You might want to create box plots of the two groups. If the boxes are approximately the same size and shape, but one is offset from the other, then an M-W test would be a way to test whether the medians are different.

For an introduction to nonparametric tests, including how to perform a M-W test by using PROC NPAR1WAY, see http://analytics.ncsu.edu/sesug/2004/TU04-Pappas.pdf

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-27-2012 12:15 PM

Look at the MEDIAN test available in NPAR1WAY.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

11-27-2012 01:45 PM

It was always my understanding that the median test in PROC NPAR1WAY was a non-parametric test of means, not of medians.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-27-2012 02:04 PM

The mean is never mentioned in the definition of the test. My experience is that this test isn't very powerful which might explain why it is so rarely used. - PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-27-2012 12:18 PM

You can also use proc freq. Take a look at http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_intronpar_se...

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

11-27-2012 01:46 PM

Arthur Tabachneck wrote:

I don't see the word "median" anywhere in the PROC FREQ documentation.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-27-2012 02:02 PM

: I'll have to leave it to , or another statistician to provide the correct answer but, the following is in the documentation:

SAS/STAT software provides the following nonparametric tests for comparing the locations of two related

samples:

Wilcoxon signed rank test

sign test

McNemar’s test

The first two tests are available in the UNIVARIATE procedure, and the last test is available in the FREQ

procedure. When you perform these tests, your data should consist of pairs of measurements for a random

sample from a single population. For example, suppose your data consist of SAT scores for students before

Tests for k Samples F 281

and after attending a course on how to prepare for the SAT. The pairs of measurements are the scores before

and after the course, and the students should be a random sample of students who attended the course. Your

goal in analysis is to decide whether the median change in scores is significantly different from zero.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

11-27-2012 02:23 PM

Arthur Tabachneck wrote:

"When you perform these tests, your data should consist of pairs of measurements for a random

sample from a single population."

Okay, that does not describe my situation.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-27-2012 03:13 PM

Then PG's answer at #1 is what you need--the median test in PROC NPAR1WAY.

Steve Denham

Solution

07-06-2017
08:55 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

11-27-2012 03:23 PM

I'm not an expert, but I believe that the Mann-Whitney (aka, Wilcoxon-Mann-Whitney or just Wilcoxon) test is generally used as an alternative to a *t *test when the data are not normally distributed. The Mann-Whitney test is commonly regarded as a test of population medians, but this is technically only true if the two populations have the same shape and one is a "translation" (or shift) of the other. If the populations have different scales and shape, the M-W test will detect that as well, which tends to muddy the results.

You might want to create box plots of the two groups. If the boxes are approximately the same size and shape, but one is offset from the other, then an M-W test would be a way to test whether the medians are different.

For an introduction to nonparametric tests, including how to perform a M-W test by using PROC NPAR1WAY, see http://analytics.ncsu.edu/sesug/2004/TU04-Pappas.pdf

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-29-2012 11:42 AM

You can use PROC QUANTREG. Suppose you have two variables, y1 and y2, that potentially have different medians. Create a new variable y that is just y1 stacked on top of y2, and create a dummy variable x that has a value of 0 if an observation is from y1 and a value of 1 if an observation is from y2. Now you can use QUANTREG to estimate the median conditional on the value of x. The TEST statement performs a WALD test of whether the effect of x is significantly different from 0.

Here is a sample program that demonstrates:

data one;

call streaminit(736283);

do i = **1** to **100**;

if i<**51** then y=rand('NORMAL',**0**,**1**);

if i<**51** then x=**0**;

if i>=**51** then y=rand('NORMAL',**1**,**1**);

if i>=**51** then x=**1**;

output;

end;

run;

proc **quantreg** data=one;

class x;

model y=x;

test x;

run;

The resulting Wald test statistic is 13.2403, the p-value is 0.0003.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AllenMcDowell

11-29-2012 11:59 AM

Thanks, Allen. That looks like a reasonable approach. Do you have any references on the Wald test? I don't really find much in SAS docs for PROC QUANTREG about the Wald test.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-29-2012 01:34 PM

The mathematical details of the Wald test are provided at:

You can also perform a likelihood ratio test by specifying the LR option in the TEST statement; the mathematical details are provided on this same page.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AllenMcDowell

11-29-2012 03:01 PM

AllenMcDowell wrote:

The mathematical details of the Wald test are provided at:

You can also perform a likelihood ratio test by specifying the LR option in the TEST statement; the mathematical details are provided on this same page.

With all due respect, there are no mathematical details of the Wald test at this link.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-29-2012 03:07 PM

Sorry, wrong link. try this one:

or look at the Details section and select the "Linear Test" entry.