1 ' SELECTING A RANDOM SAMPLE
2 ' Written by Tracy L. Gustafson, M.D.
3 ' Round Rock, Texas. Version 3.0, 1984
4 ON ERROR GOTO 5000:CHAIN MERGE "EPIMRG",5
15 DIM CX(10),CC(10),EX(10)
22 DATA "SELECTING A RANDOM SAMPLE",22,27
30 LOCATE 7,5:PRINT "Do you want to:":PRINT
35 PRINT TAB(10);"1.) Select a SURVEY SAMPLE from a population,":PRINT
40 PRINT TAB(10);"2.) Assign UNPAIRED subjects to 2 groups prospectively."
45 PRINT:PRINT TAB(10);"3.) Assign PAIRED subjects to 2 groups prospectively."
50 LOCATE 16,20:INPUT"Enter choice: ",ASUB:IF ABS(ASUB-2)>1 THEN BEEP:GOTO 50
55 LOCATE 20,5:INPUT "Do you want numbers printed on screen or printer? (S or P) ",A$
60 IF A$="p" OR A$="P" THEN PO$="LPT1:":PMAX=PRNT-10 ELSE IF A$="S" OR A$="s" THEN PO$="SCRN:":PMAX=70 ELSE BEEP:GOTO 55
65 ON ERROR GOTO 5070:OPEN PO$ FOR OUTPUT AS #1:IF PO$="LPT1:" THEN WIDTH #1,255:PRINT #1,TYP$;
70 CLS:ON ASUB GOTO 75,135,220
75 PRINT TAB(24);"SELECT A SURVEY SAMPLE":PRINT TAB(24);STRING$(22,205)
80 PRINT:PRINT TAB(15);:INPUT "What is the smallest number you want? ",E1
85 PRINT TAB(16);:INPUT "What is the largest number you want? ",E2
90 PRINT TAB(7);"How many random numbers between";E1;"and";E2;:INPUT "do you want? ",NM
95 ERASE EX:DIM EX(NM+1)
100 PRINT:PRINT #1,TAB(PMAX/2-15);NM;"RANDOM NUMBERS BETWEEN";E1;"AND";E2
105 PRINT #1,:GOSUB 210:XN=NM/(E2-E1)
110 NT=1:FOR EZ=E1 TO E2:RN=RND:IF RNNM THEN 120
115 NEXT:IF NT<=NM THEN 110
120 TB=6:IF E2>10000 THEN TB=10
125 GOSUB 215:T=1:FOR Z=1 TO NM:PRINT #1,TAB(T);EX(Z);:T=T+TB:IF T>PMAX THEN T=1
130 NEXT:PRINT #1,:GOTO 265
135 PRINT TAB(24);"ASSIGN SUBJECTS TO TWO GROUPS":PRINT TAB(24);STRING$(29,205)
140 LOCATE 4,2:INPUT "Will subjects enter the study over a period of time longer than 1 month? ",A$:PRINT:AF=0
145 IF A$="y" OR A$="Y" THEN AF=1:PRINT "Then it is preferable to randomize SUBSETS independently to avoid seasonal bias":PRINT TAB(15);"and to asssure equal numbers of cases and controls":PRINT TAB(23);"should the study terminate early.":PRINT
150 D1="How many subjects ":IF AF=1 THEN PRINT TAB(5);D1;:INPUT "are expected to enter the study each month? ",NM ELSE PRINT TAB(13);D1;:INPUT "(total) will be in the study? ",NM
155 ERASE CX,CC:DIM CX(NM/2+1),CC(NM/2+1):PRINT
160 PRINT #1,TAB(PMAX/2-13);"RANDOM ASSIGNMENT OF";NM;"SUBJECTS":PRINT #1,
165 GOSUB 210:NX=INT(NM/2)
170 NT=1:NC=1:FOR Z=1 TO NM:RN=RND:IF RN<.5 AND NT<=NX THEN CX(NT)=Z:NT=NT+1 ELSE IF NC<=NM-NX THEN CC(NC)=Z:NC=NC+1
175 NEXT:IF NTPMAX THEN T=11
190 NEXT
195 PRINT #1,:PRINT #1,:PRINT #1,"CONTROLS =";:T=11
200 FOR Z=1 TO NM-NX:PRINT #1,TAB(T);CC(Z);:T=T+7:IF T>PMAX THEN T=11
205 NEXT:PRINT #1,:GOTO 265
210 RANDOMIZE (VAL(RIGHT$(TIME$,2))):COLOR 23:AR=CSRLIN:PRINT TAB(30);"RANDOMIZING";:COLOR CLR1:RETURN
215 LOCATE AR,1:PRINT TAB(79):LOCATE AR,1:PLAY "MB T160 O3 L20 D-FA-F D- L12 FA-F L4 D-":RETURN
220 PRINT TAB(18);"ASSIGN PAIRED SUBJECTS TO TWO GROUPS":PRINT TAB(18);STRING$(36,205)
225 LOCATE 4,12:INPUT "How many PAIRS of subjects are in the study? ",NM
230 PRINT TAB(7);"Each member of a pair is assigned #1 or #2 on the basis of"
235 PRINT TAB(9);"alphabetical order or some other objective criterion."
240 PRINT #1,:PRINT #1,TAB(PMAX/2-20);"RANDOM ASSIGNMENT OF";NM;"PAIRS TO TWO GROUPS":PRINT #1,
245 PRINT #1,TAB(PMAX/3);"#1 IN PAIR";TAB(PMAX*2/3);"#2 IN PAIR"
250 RANDOMIZE VAL(RIGHT$(TIME$,2)):PRINT #1,:D1="CASE":D2="CONTROL"
255 FOR Z=1 TO NM:PRINT #1,TAB(10);Z;:RN=RND:PRINT #1,TAB(PMAX/3+2);:IF RN<.5 THEN PRINT #1,D1;TAB(PMAX*2/3+2);D2 ELSE PRINT #1,D2;TAB(PMAX*2/3+2);D1
260 NEXT
265 CLOSE #1:LOCATE 25,15:INPUT;"Do you want to perform another randomization? ",A$:IF A$="y" OR A$="Y" THEN 20
270 LOCATE 23,1:END
5000 BEEP:IF ERR<>53 AND ERR<>71 THEN 5010 ELSE LOCATE 10,10:PRINT "Please place EPISTAT in drive A: (or other default).":PRINT TAB(25);"Press any key to continue:"
5005 A$=INKEY$:IF A$="" THEN 5005 ELSE RESUME
5010 ON ERROR GOTO 0:END