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 NT53 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