Lower Confidence Limits for CPL and CPU

 /****************************************************************/
 /*       S A S   S A M P L E   L I B R A R Y                    */
 /*                                                              */
 /*    NAME: CPLUCON                                             */
 /*   TITLE: Lower Confidence Limits for CPL and CPU             */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Capability Analysis, Capability Indices,            */
 /*   PROCS: CAPABILITY IML                                      */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: Chou Y., Owen D. B., Borrego S. A. (1990).          */
 /*          "Lower Confidence Limits on Process Capability      */
 /*          Indices". Journal of Quality Technology 22, 223-229.*/
 /*                                                              */
 /*   NOTES: This program computes confidence limits for CPL and */
 /*          CPU using the method of COB (1990).                 */
 /*                                                              */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/

  options ps=60 ls=80;

  data a;
    input x @@;
    cards;
      1.38  1.49  1.43  1.60  1.59
      1.34  1.44  1.64  1.83  1.57
      1.45  1.74  1.61  1.39  1.63
      1.73  1.61  1.35  1.51  1.47
      1.46  1.41  1.56  1.40  1.58
      1.43  1.53  1.53  1.58  1.62
      1.58  1.46  1.26  1.57  1.41
      1.53  1.36  1.63  1.36  1.66
      1.49  1.55  1.67  1.41  1.39
      1.75  1.37  1.36  1.86  1.49
      ;

  proc capability data=a noprint;
    spec lsl=0.8 usl=2.4;
    var x;
    output out  = summary
           n    = n
           mean = mean
           std  = std
           cpu  = cpu
           cpl  = cpl
           lsl  = lsl
           usl  = usl ;

  proc iml;
  use summary;
  read all var {n,mean,std,cpu,cpl,usl,lsl};

  start findcx(level,n,cpx) global(t1,nn,kk);
    t1 = 3*cpx*sqrt(n/(n-1));
    kk = lgamma(0.5*(n-1))+(0.5*(n-3)*log(2));
    nn = n;
    cx = 0;
    po = 1;
    ini:
       if(po<0.99|po<level) then goto fin;
       cx = cx+(1/sqrt(n));
       po = prob(cx);
       goto ini;
    fin:
    dl = 1;
    do while(abs(dl)>1.0E-5);
       p1 = prob(cx);
       p2 = prob(cx*1.001);
       dr = (p2-p1)*1000/cx;
       dl = p1/dr*log(level/p1);
       cx = cx+dl;
    end;
    return(cx);
  finish;

  start prob(cx) global(t1,nn,kk,delta);
    delta = 3*sqrt(nn)*cx;
    inter = 0||.P;
    call quad(y,"fun",inter) peak=sqrt(nn-1) scale=0.1;
    return(y);
  finish;

  start fun(x) global(t1,delta,nn,kk);
    y = probnorm((t1*x)-delta);
    y = y*exp((nn-2)*log(x)-(0.5*x*x)-kk);
    return(y);
  finish;

  reset noname;
  level = 0.95;
  cl    = findcx(level,n,cpl);
  cu    = findcx(level,n,cpu);

  print ,;
  row =  {"     Sample Size            ",
          "     Mean                   ",
          "     Standard Deviation     " };
  rowl = {"     LSL                    ",
          "     Lower Confidence Limit ",
          "     CPL                    " };
  rowu = {"     USL                    ",
          "     Lower Confidence Limit ",
          "     CPU                    " };

  aux  = n//mean//std;
  auxl = lsl//cl//cpl;
  auxu = usl//cu//cpu;

  mattrib aux  rowname=(row) format=6.2;
  mattrib auxl rowname=(rowl) format=6.2;
  mattrib auxu rowname=(rowu) format=6.2;
  print "   Summary Statistics";
  print aux;
  print "   95% Lower Confidence Limit for CPL";
  print auxl;
  print "   95% Lower Confidence Limit for CPU";
  print auxu;

  quit;
  run;