/* SAS example of Friedman's test: */ /* Four varieties of soybean were planted in each of three separate regions of a field. The resulting yields were: Variety A B C D E Region 1 45 48 43 41 44 2 49 45 42 39 41 3 38 39 35 36 40 */ /* The response is yield */ /* The treatments are the different varieties */ /* The blocks are 3 different regions */ DATA soy; INPUT variety $ region yield; CARDS; A 1 45 A 2 49 A 3 38 B 1 48 B 2 45 B 3 39 C 1 43 C 2 42 C 3 35 D 1 41 D 2 39 D 3 36 E 1 44 E 2 41 E 3 40 ; run; PROC FREQ DATA=soy; TABLES region*variety*yield / 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 (regions): */ PROC SORT DATA=soy; BY region; PROC RANK DATA=soy OUT=yldrnks; BY region; VAR yield; PROC PRINT DATA=yldrnks; run;