05-11-2017 02:14 PM
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.
05-11-2017 02:57 PM
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
05-11-2017 02:57 PM
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
05-11-2017 03:43 PM
Thanks, this was helpful.
From your reply and other research, I think I understand it better.
Kind Regards.
Need further help from the community? Please ask a new question.