Resources

Macro for ANOM with Equal Sample Sizes

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: ANOMH1                                              */
 /*   TITLE: Macro for ANOM with Equal Sample Sizes              */
 /* PRODUCT: SAS                                                 */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: ANOM, Analysis of Means,                            */
 /*   PROCS:                                                     */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: L.S. Nelson (1983), 'Exact Critical Values for      */
 /*          Use with the Analysis of Means'. Journal of Quality */
 /*          Technology 15, pp. 40-44.                           */
 /*                                                              */
 /*          D.O. Fulenwider (1988), 'Using SAS Software for     */
 /*          Analysis of Means', "SAS Users Group International: */
 /*          Proceedings of the Thirteenth Annual Conference,    */
 /*          1212-1219.                                          */
 /*                                                              */
 /*   NOTES: This macro is designed to provide the critical      */
 /*          values needed for use with the analysis of means.   */
 /*          The values are valid for the analysis of means of   */
 /*          equal sample sizes for significance levels of .10,  */
 /*          .05, .01, and .001 .  The values generated are      */
 /*          approximate values with the absolute maximum        */
 /*          deviation from the true table values to be less     */
 /*          than one in the third significant digit.            */
 /*                                                              */
 /****************************************************************/

 %macro anomh1(alpha,df,k);

 %global halpha;

 data _null_;

 /* Check for errors in arguments of the function */

 if &df lt 3 then do;
    put  ' Error: the degrees of freedom are less than 3';
    abort;
    end;
 if &k gt &df then do;
    put ' Error:  the number of means is greater than the number of'
    '  degrees of freedom.  degrees of freedom for error should be'
    '  k(n-1).  check your input.';
    abort;
    end;

 /* Build arrays to contain the constants to be used for    */
 /* approximating the halpha values.                        */

 if &alpha=.10 then do;
    array b100{8}  b1-b8;
          b100{1}= 1.2092;
          b100{2}= 0.7992;
          b100{3}= 0.6238;
          b100{4}= 0.4797;
          b100{5}= 1.6819;
          b100{6}=-0.2155;
          b100{7}= 0.4529;
          b100{8}=-0.6095;
       end;
 if &alpha=.05 then do;
    array b050{8}  b1-b8;
          b050{1}= 1.7011;
          b050{2}= 0.6047;
          b050{3}= 0.7102;
          b050{4}= 1.4605;
          b050{5}= 1.9102;
          b050{6}= 0.2250;
          b050{7}= 0.6300;
          b050{8}=-0.2202;
       end;
 if &alpha=.01 then do;
    array b010{8}  b1-b8;
          b010{1}= 2.3539;
          b010{2}= 0.5176;
          b010{3}= 0.7107;
          b010{4}= 4.3161;
          b010{5}= 2.3629;
          b010{6}= 4.6400;
          b010{7}= 1.8640;
          b010{8}= 0.3204;
       end;
 if &alpha=.001 then do;
    array b001{8}  b1-b8;
          b001{1}= 3.1981;
          b001{2}= 0.3619;
          b001{3}= 0.7886;
          b001{4}= 8.3489;
          b001{5}= 3.1003;
          b001{6}=27.7005;
          b001{7}= 5.1277;
          b001{8}= 0.7271;
       end;

 k1 = log(&k);
 k2 = log(&k-2);
 v1 = 1/(&df-1);
 halpha = b1 + b2*(k1**b3) + (b4 + b5*k1)*v1 +
         (b6 + b7*k2 + b8*k2*k2)*v1**2;
   call symput('halpha',left(put(halpha,8.3)));

 %mend anomh1;