75 AC=29:GOSUB 4800:AX=VAL(IP$):IF AX<>0 AND AX<>1 THEN AC=29:D1="cases":AA=0:D2="1":GOSUB 210:GOTO 75
80 AC=56:GOSUB 4800:BX=VAL(IP$):IF BX>AM THEN AC=56:D1="controls":AA=AM:D2="less":GOSUB 210:GOTO 80
85 CX=AX+BX:HX=HX+CX:HX2=HX2+CX*CX:XBT=XBT+BX:IF AX=1 THEN XBC=XBC+BX
90 NEXT Z:PRINT STRING$(66,196):GOTO 145
95 LOCATE 8,1:GOSUB 40:PRINT TAB(15);"What is the SAMPLE NUMBER of the CASE group?";:AR=9:AC=62:GOSUB 4200:NS(1)=NS
100 PRINT TAB(12);"What are the";AM;"SAMPLE NUMBERS of the CONTROL groups?"
105 FOR Z=2 TO AM+1:AR=CSRLIN:AC=62:GOSUB 4200:NS(Z)=NS:NEXT Z
110 FOR Z=2 TO AM+1:IF T(NS(1))<>T(NS(Z)) THEN BEEP:PRINT " These samples do not all have the same number of elements----": PRINT TAB(25);"a paired Mantel-Haenszel test cannot be performed.":GOTO 195
115 NEXT:XBT=0:XBC=0:HX=0:HX2=0
120 FOR Z=1 TO T(NS(1)):XA=VAL(D(NS(1),Z)):XB=0:IF ABS(XA-0.5)>0.51 THEN 205
125 FOR T=2 TO AM+1:QX=VAL(D(NS(T),Z)):XB=XB+QX:IF ABS(QX-0.5)>0.51 THEN 205
130 NEXT
135 XC=XA+XB:HX=HX+XC:HX2=HX2+XC*XC:XBT=XBT+XB:IF XA=1 THEN XBC=XBC+1
175 COLOR CLR2,CLR1:PRINT TAB(34);"p = ";:IF P<9.99E-07 THEN PRINT "< 10 (-6)"; ELSE PRINT P;
180 PRINT TAB(66):COLOR CLR1,CLR2:PRINT:PRINT:PRINT TAB(33);"ODDS RATIO = ";
185 IF XBT=XBC THEN PRINT "not calculable.":GOTO 195 ELSE XO=(AM*(HX-XBT)-XBC)/(XBT-XBC):PRINT XO
190 XP=1.96/SQR(X):PRINT TAB(16);"95% Confidence limits: ";EXP((1-XP)*LOG(XO));" and ";EXP((1+XP)*LOG(XO))
195 LOCATE 25,8:PRINT TAB(79):LOCATE 25,12:INPUT;" Do you want to calculate another Mantel-Haenszel test? ",A$:IF A$="y" OR A$="Y" THEN 20
200 GOTO 3000
205 BEEP:PRINT:PRINT:PRINT TAB(25);"An error in data entry was detected:":PRINT " All records should contain a "1" if factor is present, a "0" if it is absent.":PRINT:GOTO 195
210 BEEP:LOCATE 25,8:PRINT "The number of positive ";D1;" per group should be";AA;"or ";D2;TAB(79):RETURN
4010 IF FILE$="" THEN 45
4025 ERASE D,CS,N$,X,X2,T,SD,MD,NS
4030 DIM D(A,C),CS(A,C),N$(A),X(A),X2(A),T(A),SD(A),MD(A),NS(A)
5000 BEEP:IF ERR<>53 AND ERR<>71 THEN 5010 ELSE LOCATE 2,10:PRINT "Please place EPISTAT in drive A: (or other default).":PRINT TAB(25);"Press any key to continue:"