BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ilikesas
Barite | Level 11

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! 

1 ACCEPTED SOLUTION

Accepted Solutions
ilikesas
Barite | Level 11

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.

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_npar1way_det...

 

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

 

https://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_anova_sect0...

 

  

View solution in original post

9 REPLIES 9
Reeza
Super User

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. 

ilikesas
Barite | Level 11

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;
Reeza
Super User

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

 

 

ilikesas
Barite | Level 11

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

ilikesas
Barite | Level 11

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! 

Reeza
Super User

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

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

ilikesas
Barite | Level 11

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.

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_npar1way_det...

 

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

 

https://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_anova_sect0...

 

  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 5621 views
  • 4 likes
  • 2 in conversation