- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Good evening, I'm a beginner in using the sas program. I found dependent nonparametric data that I would like to analyze the compliance of mean values at. I found out, it should be through Wilcoxon Sign Rank test. Bud I have no idea how to write the proc npar1way in this case. Can you help me pleace? Btw: I have no qualitative variable is there an ability to do it withou this variable (just to use var and not also the class). I found just how to do Wilcoxon Rank Sum test, but I need the oter one for the dependent data. Thank you for soon reaction.
Number of sheeps/100 ha in 2000 | Number of sheeps/100 ha 2017 | |
Bratislava I-V | 3,20 | 6,00 |
Malacky | 0,50 | 0,90 |
Pezinok | 0,80 | 1,20 |
Senec | 0,40 | 0,20 |
Dunajská Streda | 1,00 | 0,90 |
Galanta | 0,70 | 0,90 |
Hlohovec | 0,00 | 1,50 |
Piešťany | 1,20 | 1,70 |
Senica | 1,70 | 0,20 |
Skalica | 0,40 | 2,30 |
Trnava | 0,70 | 0,60 |
Bánovce nad Bebravou | 7,50 | 5,40 |
Ilava | 35,90 | 21,80 |
Myjava | 4,10 | 3,70 |
...and so on...there is 71 observations totally
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you're looking for the Wilcoxon Two Sample Test, that would be NPAR1WAY, but it requires your data to be in a different format - stacked with year as a variable to include as the categorical variable. You can transform your data using PROC TRANSPOSE.
There's a full example for the test in the SAS documentation:
data React; input Stim Time @@; datalines; 1 1.94 1 1.94 1 2.92 1 2.92 1 2.92 1 2.92 1 3.27 1 3.27 1 3.27 1 3.27 1 3.70 1 3.70 1 3.74 2 3.27 2 3.27 2 3.27 2 3.70 2 3.70 2 3.74 ; proc npar1way wilcoxon correct=no data=React; class Stim; var Time; exact wilcoxon; run;
With N=71 the Central Limit Theorom applies and you could use the t-test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Good evening, Monika, and welcome to the SAS Support Communities!
The Wilcoxon signed rank test is provided by PROC UNIVARIATE, not PROC NPAR1WAY (see documentation: Tests for Location). First, you compute the difference between the two values for each pair, then you use this difference as the analysis variable in a PROC UNIVARIATE step. If you haven't created a SAS dataset from your data yet, you can compute the differences in the same data step, as shown below (I use datalines, but you would typically read from an external file specified in an INFILE statement):
/* Read raw data and compute differences */
data want;
input @1 site $25.
@26 n2000 numx5.
@32 n2017 numx5.;
d=n2017-n2000;
cards;
Bratislava I-V 3,20 6,00
Malacky 0,50 0,90
Pezinok 0,80 1,20
Senec 0,40 0,20
; /* ... more data ... */
/* Perform Wilcoxon signed rank test */
proc univariate data=want;
var d;
run;
If your data is already available in a SAS dataset (let's call it HAVE), simply compute the differences like this:
data want;
set have;
d=n2017-n2000;
run;
The output from PROC UNIVARIATE contains a table "Tests for Location," in which you find the test statistic and p-value of the (two-sided) Wilcoxon signed rank test in the third row (highlighted below):
Tests for Location: Mu0=0 Test -Statistic- -----p Value------ Student's t t 1.277798 Pr > |t| 0.2912 Sign M 1 Pr >= |M| 0.6250 Signed Rank S 4 Pr >= |S| 0.2500
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you're looking for the Wilcoxon Two Sample Test, that would be NPAR1WAY, but it requires your data to be in a different format - stacked with year as a variable to include as the categorical variable. You can transform your data using PROC TRANSPOSE.
There's a full example for the test in the SAS documentation:
data React; input Stim Time @@; datalines; 1 1.94 1 1.94 1 2.92 1 2.92 1 2.92 1 2.92 1 3.27 1 3.27 1 3.27 1 3.27 1 3.70 1 3.70 1 3.74 2 3.27 2 3.27 2 3.27 2 3.70 2 3.70 2 3.74 ; proc npar1way wilcoxon correct=no data=React; class Stim; var Time; exact wilcoxon; run;
With N=71 the Central Limit Theorom applies and you could use the t-test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for so quick reaction on my question. I´m looking forward to further cooperation :).