Resources

Analysis of Means with Unequal Sample Sizes


 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: ANOMX2                                              */
 /*   TITLE: Analysis of Means with Unequal Sample Sizes         */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: ANOM, Analysis of Means,                            */
 /*   PROCS: SHEWHART                                            */
 /*    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 sample program uses the anomh2 macro defined   */
 /*          in sample program ANOMH2.  Those statements must be */
 /*          submitted before this sample program.               */
 /*                                                              */
 /****************************************************************/

 data example2;
   input aggregt $ moisture ;
   cards;
 1    551
 1    457
 1    450
 1    731
 1    499
 1    632
 2    595
 2    580
 2    508
 2    583
 2    633
 3    639
 3    615
 3    511
 3    573
 4    417
 4    449
 4    517
 4    438
 5    563
 5    631
 5    522
 ;

 proc shewhart data=example2;
    xchart moisture*aggregt /
          nochart
          stddevs
          smethod=rmsdf
          outhistory=hist2
          outlimits=lim2;
    run;

 data hist2a;
    retain sumni 0;
    set hist2 end=eof;
    _phase_=aggregt;
    sumni+moisturen;
    if eof then do;
       set lim2(keep=_stddev_);
       mse=(_stddev_*c4(sumni - (_n_ -1)))**2;
       msedf=sumni-_n_;
       call symput('mse',left(put(mse,8.3)));
       call symput('msedf',left(put(msedf,8.)));
       call symput('ntrt',left(put(_n_,8.)));
       call symput('totn',left(put(sumni,8.)));
       end;
 run;

 /* NOTE: alpha level is .05, halpha is calculated */

 %anomh2(.05,&msedf,&ntrt);
 run;

 data lim2a;
    retain _var_ _subgrp_ _sigmas_ _alpha_ _mean_;
    length _index_ $ 4.;
    if _n_ =1 then set lim2;
    set hist2(keep=moisturen);
    _index_=_n_;
    halpha=&halpha;
    hdelta=&halpha*sqrt(&mse)*sqrt((&totn-moisturen)/
                                   (&totn*moisturen));
    _lclx_=_mean_-hdelta;
    _uclx_=_mean_+hdelta;
    _stddev_=sqrt(&mse);
    _limitn_=moisturen;
    _alpha_=.05;
    output;

 symbol1 v=none h=3 w=20 f=;
 title1 font=swiss h=1.5 c=black 'Analysis of Means';
 title2 font=swiss h=.9 c=black 'Unequal Sample Sizes';
 proc shewhart history=hist2a limits=lim2a;
   xchart moisture*aggregt/
          stddevs
          tableout
          readphases=('1' '2' '3' '4' '5')
          readindexes=('1' '2' '3' '4' '5')
          readalpha
          ct=black
          climits=black
          ca=black
          font=swiss
          noconnect
          cneedles=green
          cout=orange
          cframe=lio
          nolegend
          ucllabel='UDL'
          lcllabel='LDL'
          haxis=(' ' '1' '2' '3' '4' '5' ' ');
    label moisturex= 'Moisture Absorption'
          aggregt= 'Concrete Aggregate';
 run;