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
- /
- median and mean tests for several classes

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
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-25-2016 07:13 PM

Hi,

ususally when doing a median test I use the proc npar1way - I have a certain data variable with divised into 2 classes and i d the test to compare the medians for each class.

But when I have more than 2 classes, say 3, then I have to make proc npar1way 3 times because I have 3 pairs. Is it possible for SAS to do all the different pairwise median tests within the same procedure (like this don't have to repeat the same procedure 3 times)?

Same question applies for the mean test proc ttest.

Thank you!

Accepted Solutions

Solution

10-27-2016
11:42 PM

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

10-27-2016 11:42 PM

Thanks Reeza for the guidance. I will summarize here the discussion and put it as the solution like this its clear to future readers:

1) Median test: it is done with proc npar1way for 2 samples. Can do pairwise median comparison for more than 2 samples if add the DSCF option. But note that the DSCF method deosn't include a continuity correction in the Wilcoxon test statistic, while "normal" proc npar1way for 2 samples by dfault does (although you can include the "correction=no" option so it doesn't.

2) Mean test: for 2 samples it is done with proc ttest. Can do pairwise mean comparison for more than 2 samples with proc GLM and ANOVA, but should read the docs for the details:

http://support.sas.com/kb/45/428.html

All Replies

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

10-25-2016 09:40 PM

This is called pairwise comparison.

You can do it in certain procs and not others. PROC GLM/ANOVA will allow pairwise comparison, unfortunately NPAR1WAY doesn't have pairwise AFAIK.

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

10-25-2016 09:53 PM

And google proves me wrong...

look at the DSCF on the PROC NPAR1WAY statement.

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

10-25-2016 11:54 PM

Hi Reeza,

I tried the DSCF and it worked, but the results that I get with DSCF are somewhat different than when I am doing an individual pair median comparison. Is it normal?

Here is the code

```
data test3;
set test;
if group =1 or group =3;
run;
/*for the individual pair wilcoxon test*/
ods graphics off;
ods output wilcoxontest=a_3;
proc npar1way data=test3 wilcoxon median ;
var data;
class group;
run;
/*using DSCF*/
proc npar1way data=test dscf ;
var data;
class group;
run;
```

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

10-26-2016 12:14 AM

define different. I can't see your data or output.

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

10-26-2016 12:26 AM

here is my original data "test":

data test; input data group; datalines; 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 ; run;

when I do the dscf option:

```
/*using DSCF*/
ods graphics off;
ods output dscf=b;
proc npar1way data=test dscf ;
var data;
class group;
run;
```

I get a Wilcoxon Z = -3.7033 for group 1 vs group 3.

Whereas when I do a regular median test using group 1 and group 3:

```
data test1_3;
set test;
if group =1 or group =3;
run;
/*for the individual pair wilcoxon test*/
ods graphics off;
ods output wilcoxontest=a_3;
proc npar1way data=test1_3 wilcoxon median ;
var data;
class group;
run;
```

I get a Wilcoxon Z = 3.6647

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

10-26-2016 12:44 AM

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

10-26-2016 01:10 AM

ok I think I understand, its becasue the DSCF method deosn't include a continuity correction in the Wilcoxon test statistic.

And in fact, when I did a regular 2 sample npar1way median test and included the "correction = no" option, I got the same Wilcoxon Z as with the DSCF method.

Is it possible to include the continuity correction when doing the DSCF method? If no, I guess this will answer the first part of my question.

As for the second part, is it possible to compare the means of several samples in one step? When I used proc ttest and included more than 2 classes I got an error message that there are more than 2 levels.

Thank you!

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

10-26-2016 01:25 AM

Ttests are between two samples. ANOVA is for more than 2 samples.

It probably has a multiple comparison option if you check the docs.

Solution

10-27-2016
11:42 PM

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

10-27-2016 11:42 PM

Thanks Reeza for the guidance. I will summarize here the discussion and put it as the solution like this its clear to future readers:

1) Median test: it is done with proc npar1way for 2 samples. Can do pairwise median comparison for more than 2 samples if add the DSCF option. But note that the DSCF method deosn't include a continuity correction in the Wilcoxon test statistic, while "normal" proc npar1way for 2 samples by dfault does (although you can include the "correction=no" option so it doesn't.

2) Mean test: for 2 samples it is done with proc ttest. Can do pairwise mean comparison for more than 2 samples with proc GLM and ANOVA, but should read the docs for the details:

http://support.sas.com/kb/45/428.html