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

This is one of those, "I knew how to do it in the other program, but how to in SAS" questions.

 

I need to do a Wilcoxon Mann-Whitney test.

 

The data comes as;

 

 

SUBJ

TIME

TEST

01

1

3.4

01

2

3.5

02

1

2.4

02

2

3.5

 

In the pasT, I would explain transpose a wide format, like this.

 

SUBJ

TEST_1

TEST_2

01

3.4

3.5

02

2.4

3.5

 
 

Then I write my wilcoxon to compare TEST_1 to TEST_2, which is sort of like (TEST_2 - TEST_1=DIFF).

 

But SAS seems to want to use the first data structure.  It wants me to use a VARIABLE and a CLASS, (with only 2 values in the CLASS column.)

 

How do I write the procedure so I can ensure that the order of operations is going the right way, as in, that I'm subtracting TEST_1 from TEST_2 and not the other way around?

 

I used the documentation from the NPAR1WAY to get some results, but I don't feel that I'm getting the same info I'm used to.

 

Here is a sample of my code.

 

ods graphics on;
proc npar1way data=my.data

plots=all;
where time=1 or time=2;
var test;
class time;
run;
ods graphics off;

 

I am comparing TIME1 against TIME2.

 

I guess my question is partly statistical.  Does the p-value consider the result as an absolute result, not caring if the difference was positive or negative?  The Null Hypothese says they are equal, so whether the difference is good or bad, doesn't really show in the p-value.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Good questions. I am not an expert in this area, but I think the answers are:

1.If you want to use the wide data, you can use PROC FREQ:

proc freq data=my.data;

tables test_1*test_2 / cmh2 chisq scores=rank;

run;

However, NPAR1WAY does a continuity correction by default, whereas PROC FREQ does not, so the answers are slightly different.

 

2. Yes, you need to use long data for NPR1WAY. I think the answer is that it doesn't matter which sample is "Sample 1" and which is "Sample 2". There is a statement as such in the Wikipedia article. The SAS doc tells you that SAS uses the size of the groups to determine which is "Sample 1" and which is "Sample 2": The doc says "To compute the linear rank statistic S, PROC NPAR1WAY sums the scores of the observations in the smaller of the two samples. If both samples have the same number of observations, PROC NPAR1WAY sums those scores for the sample that appears first in the input data set."

 

HTH

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Good questions. I am not an expert in this area, but I think the answers are:

1.If you want to use the wide data, you can use PROC FREQ:

proc freq data=my.data;

tables test_1*test_2 / cmh2 chisq scores=rank;

run;

However, NPAR1WAY does a continuity correction by default, whereas PROC FREQ does not, so the answers are slightly different.

 

2. Yes, you need to use long data for NPR1WAY. I think the answer is that it doesn't matter which sample is "Sample 1" and which is "Sample 2". There is a statement as such in the Wikipedia article. The SAS doc tells you that SAS uses the size of the groups to determine which is "Sample 1" and which is "Sample 2": The doc says "To compute the linear rank statistic S, PROC NPAR1WAY sums the scores of the observations in the smaller of the two samples. If both samples have the same number of observations, PROC NPAR1WAY sums those scores for the sample that appears first in the input data set."

 

HTH

Jbhammon
Calcite | Level 5

Thanks, this was helpful.

 

From your reply and other research, I think I understand it better.

 

Kind Regards.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1265 views
  • 0 likes
  • 2 in conversation