Simple Dorfman Screening-Infinite

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: IEDORF1B                                            */
 /*   TITLE: Simple Dorfman Screening-Infinite                   */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Inspection Sampling,                                */
 /*   PROCS: TABULATE                                            */
 /*    DATA:                                                     */
 /*                                                              */
 /*    MISC:                                                     */
 /*                                                              */
 /*   NOTES: This program tabulates measures of effectiveness    */
 /*          for simple Dorfman screening of an infinite lot     */
 /*          under an imperfect inspection model.                */
 /*                                                              */
 /*          Notation:                                           */
 /*                                                              */
 /*          omega   = proportion of defective items in lot      */
 /*                                                              */
 /*          n0      = sample size                               */
 /*                                                              */
 /*          p       = Pr[ correctly classifying defective       */
 /*                        item ]                                */
 /*          pprime  = Pr[ incorrectly classifying a non-        */
 /*                        defective item ]                      */
 /*                                                              */
 /*          p0      = Pr[ correct classification of positive    */
 /*                        on group test ]                       */
 /*          p0prime = Pr[ incorrect classification of positive  */
 /*                        on group test ]                       */
 /*                                                              */
 /*          pcnc    = Pr[ correct classification of defective   */
 /*                        (nonconforming) item ]                */
 /*          pcc     = Pr[ correctly classifying conforming      */
 /*                        item ]                                */
 /*          save    = expected percent reduction in number of   */
 /*                    tests                                     */
 /*                                                              */
 /*     REF: Johnson, N. L., Kotz, S., and Rodriguez, R. N.      */
 /*          (1987), Statistical Effects of Imperfect Inspection */
 /*          Sampling:  III. Screening (Group Testing), Journal  */
 /*          of Quality Technology 20, 98-124.  See Table 6.     */
 /*                                                              */
 /*          Johnson, N. L., Kotz, S., and Wu, X. (1991).        */
 /*          Inspection Errors for Attributes in Quality         */
 /*          Control.  London:  Chapman & Hall.  See Chapter 6.  */
 /*                                                              */
 /****************************************************************/

data table;

   keep omega n0 p pprime p0 p0prime pcc pcnc save;

   label omega   = 'omega'
         n0      = 'n0'
         p       = 'p'
         pprime  = 'p'''
         p0      = 'p0'
         p0prime = 'p0'''
         pcc     = 'PC(C)'
         pcnc    = 'PC(NC)'
         save    = 'Exp Pct Reduction' ;

   format pcc 6.4 pcnc 6.4 save 4.1 ;

   /*---set main parameters---*/
   omega   = 0.05 ;
   p       = 0.95 ;
   pprime  = 0.05 ;
   p0      = 0.98 ;
   p0prime = 0.05 ;

   /*---loop over sample values---*/
   do n0 = 6, 8, 10, 12;

      p0star = ( 1 - omega ) ** ( n0 - 1 );
      p1star = ( p0 - p0prime ) * p0star;

      /*---find PC(C)---*/
      pcc = 1 - ( p0 - p1star ) * pprime ;

      /*---find PC(NC)---*/
      pcnc = p0 * p;

      /*---find E(number tests)---*/
      p0n   = ( 1 - omega ) ** n0;
      etest = 1 + n0 * ( p0n * p0prime + ( 1 - p0n ) * p0 );
      save  = 100 * ( 1 - etest / n0 );

      /*---output observation---*/
      output;

      end;  /* finish loop over values of n0 */

   return;  /* finish main program */

run;

proc sort data=table;
   by omega p pprime p0 p0prime;

proc print label noobs;
   by omega p pprime p0 p0prime;
   var n0 pcc pcnc save;

run;