Resources

Analysis of Means for Proportions

 /****************************************************************/
 /*       S A S   S A M P L E   L I B R A R Y                    */
 /*                                                              */
 /*    NAME: ANOMP                                               */
 /*   TITLE: Analysis of Means for Proportions                   */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: ANOM, Analysis of Means,                            */
 /*   PROCS: PRINT SHEWHART                                      */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: P. R. Nelson (1982), "Exact Critical Points for the */
 /*          Analysis of Means", Communications in Statistics,   */
 /*          A11, 699-709                                        */
 /*                                                              */
 /*          Robert N. Rodriguez (1996), "Health Care            */
 /*          Applications of Statistical Process Control:        */
 /*          Examples Using the SAS System", Proceedings of the  */
 /*          Twenty-First Annual SAS Users Group International   */
 /*          Conference, 1381-1396                               */
 /*                                                              */
 /*   NOTES: This sample program uses the anomsig macro defined  */
 /*          in the ANOMSIG sample program.  The statements in   */
 /*          that program must be submitted before this program. */
 /*                                                              */
 /****************************************************************/

 options ls=64 nodate nonumber;
 goptions htext= 3.5 pct htitle=4.0 pct
          ftext='albany amt';

 %let symht=2.4pct;

 %annomac;

 data csection;
    length id $ 2;
    input id csect94 vag94 csect95 vag95;
    total94 = csect94 + vag94;
    total95 = csect95 + vag95;
    label id = 'Medical Group Identification Number';
    cards;
 1A      163     907     150     773
 1K       55     314      45     253
 1B       52     179      34     136
 1D       19     128      18     114
 3I       21      98      20      86
 3M       15      81      12      93
 1E       15      52      10      67
 1N        6      43      19      55
 1Q       12      67       7      62
 3H        7      65      11      54
 1R        4      43      11      38
 1H        5      32       9      39
 3J        7      12       7      13
 1C       13      42       8      35
 3B        3      33       6      37
 1M        6       8       4      25
 3C        6      27       5      23
 1O        8      26       4      23
 1J        6      18       6      16
 1T        1       3       3      19
 3E        2      12       4      14
 1G        1       7       4      11
 3D        7      22       4       9
 3G        2       5       1      10
 1L        2       4       2       8
 1I        1       3       1       7
 1P       16      65       0       3
 1F        0       1       0       3
 1S        1       2       1       2
 ;

 title 'Cesarean Sections for Medical Groups';
 proc print data=csection noobs;
    var id csect94 total94 csect95 total95;
 run;

 data csect94;
    set csection end=eof;
    if eof then call symput('ngroups', left( put( _n_, 4. )));
    rate94 = csect94 / total94;
 run;

 data csect94;
    set csect94;
    %dclanno;
    %sequence(after);
    %system(2,2,3);
    function = 'symbol';
    xc       = id;
    y        = rate94;
    size     = 2.4;
    color    = 'yellow';
    text     = 'circle';
 run;

 %anomsig( 0.01, &ngroups );

 title 'Proportion of C-Sections in 1995';
 symbol v=none w=7;

 proc shewhart data=csection;
    pchart csect95*id /
       subgroupn = total95
       cframe    = blue
       sigmas    = &sigmult
       cneedles  = yellow
       haxis     = axis1
       lcllabel  = 'LDL'
       ucllabel  = 'UDL'
       nolegend
       turnhlabels;

 axis1 value = ( h=2.2 pct ) ;
 label csect95 = 'Proportion of Cesarean Sections';
 run;

 %anomsig( 0.01, &ngroups );

 title 'Proportion of C-Sections:'
       ' 1994 and 1995';
 symbol v=dot c=black h=&symht;

 proc shewhart data=csection;
    pchart csect95*id / subgroupn=total95
                        cframe = ligr
                        noconnect
                        turnhlabels
                        nolegend
                        anno   = csect94
                        lcllabel  = 'LDL'
                        ucllabel  = 'UDL'
                        haxis = axis1
                        sigmas=&sigmult;

 axis1 value = ( h=2.2 pct ) ;
 label csect95 = 'Proportion of Cesarean Sections';
 footnote j=l ' Empty Circles Indicate 1994 Rates';
 run;

 footnote;

 /* Stacked Charts */

 %anomsig( 0.01, &ngroups );

 proc shewhart data=csection;
    pchart csect94*id /
       subgroupn = total94
       sigmas    = &sigmult
       outtable =  cstab94
                   (rename = ( _lclp_ = _lclx_
                               _subp_ = _subx_
                               _p_    = _mean_
                               _uclp_ = _uclx_ ))
       nochart;

 proc shewhart data=csection;
    pchart csect95*id /
       subgroupn=total95
       sigmas   =&sigmult
       outtable =cstab95
                 (rename = ( _lclp_  = _lclr_
                             _subp_  = _subr_
                             _p_     = _r_
                             _uclp_  = _uclr_
                             _exlim_ = _exlimr_)
                  drop   = _var_ _limitn_
                           _subn_  _sigmas_ )
       nochart;

 data cstab;
    merge cstab94 cstab95;
    if _subn_ = 1 then _subr_ = . ;
 run;

 proc print data=cstab;
 run;

 title 'C-Section Rates for 1994 and 1995';

 symbol v=none w=7;

 proc shewhart table=cstab;
    xrchart csect94 *id /
       cneedles  = black
       cinfill   = ligr
       cframe    = yellow
       split     = '/'
       ypct1     = 50
       xsymbol   = 'Avg'
       rsymbol   = 'Avg'
       lcllabel  = 'LDL'
       ucllabel  = 'UDL'
       lcllabel2 = 'LDL'
       ucllabel2 = 'LDL'
       haxis     = axis1
       turnhlabel
       nolimitsleg
       nolegend ;
 axis1 value = ( h=2.2 pct ) ;
 label _subx_ = '1994 Proportion/1995 Proportion';
 run;