New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Monika1111
Calcite | Level 5

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 2000Number of sheeps/100 ha 2017
Bratislava I-V3,206,00
 Malacky0,500,90
 Pezinok0,801,20
 Senec0,400,20
 Dunajská Streda1,000,90
 Galanta0,700,90
 Hlohovec0,001,50
 Piešťany1,201,70
 Senica1,700,20
 Skalica0,402,30
 Trnava0,700,60
 Bánovce nad Bebravou7,505,40
 Ilava35,9021,80
 Myjava4,10

3,70

...and so on...there is 71 observations totally

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_np...

 

With N=71 the Central Limit Theorom applies and you could use the t-test.  

 

 

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

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

 

 

 

Reeza
Super User

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;

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_np...

 

With N=71 the Central Limit Theorom applies and you could use the t-test.  

 

 

Monika1111
Calcite | Level 5

Thank you both for so quick reaction on my question. I´m looking forward to further cooperation :).

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 13677 views
  • 1 like
  • 3 in conversation