Resources

OC Curve for p Chart

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: SHWOC2                                              */
 /*   TITLE: OC Curve for p Chart                                */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Shewhart Charts, OC Curves,                         */
 /*   PROCS: SHEWHART PLOT                                       */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: SAS/QC Software:  Examples                          */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/

options ps=60 ls=100 nodate;

data cans;
   input sample noncnfm;
   cards;
 1  12
 2  15
 3   8
 4  10
 5   4
 6   7
 7  16
 8   9
 9  14
10  10
11   5
12   6
13  17
14  12
15  22
16   8
17  10
18   5
19  13
20  11
21  20
22  18
23  24
24  15
25   9
26  12
27   7
28  13
29   9
30   6
;

data cansrev;
   set cans;
   if sample=15 or sample=23 then delete;

proc shewhart data=cansrev;
   pchart noncnfm*sample / subgroupn=50
      nochart
      outlimits=canlim2;


data ocpchart;
   set canlim2;
   keep beta fraction;
   nucl=_limitn_*_uclp_;
   nlcl=_limitn_*_lclp_;
   do p=0 to 50;
      fraction=p/100;
      if nucl=floor(nucl) then
         adjust=probbnml(fraction,_limitn_,nucl) -
                probbnml(fraction,_limitn_,nucl-1);
      else adjust=0;
      if nlcl=0 then
         beta=1 - probbeta(fraction,nucl,_limitn_-nucl+1) + adjust;
      else beta=probbeta(fraction,nlcl,_limitn_-nlcl+1) -
                probbeta(fraction,nucl,_limitn_-nucl+1) +
                adjust;
      if beta >= 0.001 then output;
      end;
   call symput('lcl', put(_lclp_,5.3));
   call symput('mean',put(_p_,   5.3));
   call symput('ucl', put(_uclp_,5.3));
run;

title "OC Curve for p Chart With LCL=&LCL, p0=&MEAN, and UCL=&UCL";
proc plot data=ocpchart;
   plot beta*fraction='*' /
      vaxis=0 to 1.0 by 0.1
      haxis=0 to 0.5 by 0.05
      vzero
      hzero;
   label fraction='Fraction Nonconforming'
         beta    ='Beta';
run;

title;