/* SAS example of Friedman's test: /* Wind example from Nigeria */ /* The response (WSR) is average wind speed reduction */ /* The treatments are the different distances for the shelterbelt */ /* The blocks are 9 different months */ DATA windspeed; INPUT month $ distance wsr; CARDS; Jan 20 22.1 Jan 40 20.7 Jan 100 15.4 Jan 150 12.3 Jan 200 6.9 Feb 20 19.2 Feb 40 18.7 Feb 100 14.9 Feb 150 9.3 Feb 200 6.5 Mar 20 21.5 Mar 40 21.9 Mar 100 14.3 Mar 150 9.9 Mar 200 7.1 Apr 20 21.5 Apr 40 21.2 Apr 100 11.1 Apr 150 9.4 Apr 200 6.2 May 20 21.3 May 40 20.9 May 100 11.2 May 150 9.4 May 200 7.7 Jun 20 20.9 Jun 40 19.6 Jun 100 16.9 Jun 150 11.6 Jun 200 7.0 Aug 20 19.3 Aug 40 18.7 Aug 100 14.4 Aug 150 12.5 Aug 200 7.0 Sep 20 20.1 Sep 40 19.6 Sep 100 15.6 Sep 150 12.6 Sep 200 7.5 Oct 20 23.7 Oct 40 20.4 Oct 100 14.6 Oct 150 12.4 Oct 200 8.5 ; run; PROC FREQ DATA=windspeed; TABLES month*distance*wsr / CMH2 SCORES=RANK NOPRINT; run; /* In SAS, the Friedman test can be done with PROC FREQ; */ /* The CMH2 SCORES=RANK option gives the Friedman test. */ /* The test statistic and P-value are given in the */ /* "Row Mean Scores Differ" row of the output. */ /**************************************************************/ /* To calculate the ranks within blocks (months): */ PROC SORT DATA=windspeed; BY month; PROC RANK DATA=windspeed OUT=windrnks; BY month; VAR wsr; PROC PRINT DATA=windrnks; run;