LIFE TABLE implements the actuarial life-table method for calculating cumulative survival and mortality probabilities across user-defined time intervals. The program accepts inputs for the number of intervals and enrolled subjects, then iterates through each interval collecting counts of “lost” (withdrawn or censored) and “dead” (event) subjects. For each interval it computes the effective exposure (number entered minus half the lost, a standard actuarial adjustment: EX = EN − L×0.5), the proportion dead, proportion surviving, and the cumulative chance of survival using the product-limit approach (multiplying successive interval survival proportions). Results are displayed in a formatted multi-section screen layout using AT-addressed PRINT statements, with values rounded to three decimal places via the INT((x + 0.0005)×1000)/1000 idiom.
Program Structure
The program divides into four logical phases:
- Introduction (lines 10–160): Sets display attributes, prints multi-screen explanatory text about the life-table method, and uses a
GO SUB 540pause-and-clear routine between screens. - Data entry preamble (lines 170–210): Collects the total number of intervals (
IN) and the initial number of subjects entered (EN). - Screen layout (lines 220–300): Prints three labeled column-header blocks at fixed screen positions using
ATto create a persistent dashboard for interval-by-interval results. - Interval loop (lines 310–530): A
FOR N=1 TO INloop processes each interval, collecting lost (L) and dead (D) counts, computing statistics, and updating the screen in-place.
Key Variables
| Variable | Role |
|---|---|
IN | Total number of time intervals |
EN | Number of subjects entering current interval |
L | Number lost/withdrawn in current interval |
D | Number of events (deaths) in current interval |
EX | Effective exposure: EN − L×0.5 |
PD | Proportion dead (interval mortality rate) |
PSN | Proportion surviving this interval |
PSO | Cumulative survival probability (carried forward) |
CCS | Updated cumulative survival: PSO × PSN |
Actuarial Method
The program faithfully implements the standard life-table (Kaplan–Meier-adjacent) technique. The effective exposure calculation at line 390 — EX = EN − L × 0.5 — applies the actuarial assumption that censored subjects (lost or withdrawn) contribute, on average, half an interval of observation. The interval mortality proportion is PD = D / EX, and cumulative survival is the running product of interval survival fractions (PSN = 1 − PD), accumulated in PSO/CCS. Cumulative mortality is derived as 1 − CCS and expressed as a percentage at line 490.
Rounding Idiom
Results are rounded to three decimal places using the classic BASIC idiom at lines 410 and 470:
INT((x + 0.0005) × 1000) / 1000
This is a standard technique to work around the absence of a built-in rounding function, adding half a unit in the last place before truncating with INT.
Screen Layout Technique
Rather than scrolling output, the program establishes three fixed display regions (rows 3–4, 11–12, 19–20) for interval header, per-interval statistics, and cumulative statistics respectively. All dynamic values are written with PRINT AT row, col;, allowing results to update in-place for each interval without redrawing the column headers. Trailing spaces (e.g., ;" " or ;" ") are used to overwrite stale digits from previous iterations — a common technique where a CLEAR or CLS would destroy the persistent header layout.
Note that PI (approximately 3.14159) is used as a row argument in several PRINT AT PI, col calls (lines 320–380, 400–440, 510). The interpreter truncates it to integer 3, so these statements all address row 3. Similarly, line 110 uses PRINT AT 5, PI, addressing column 3. This is an unconventional but functional shorthand for the integer 3.
Subroutine
Line 540 is a utility subroutine called three times (lines 50, 100, 210) that prints a prompt on the lower channel (PRINT #0), waits for a keypress with PAUSE 0, clears the screen, and returns. This is an efficient use of a single routine for all inter-screen transitions.
Notable Anomalies
- Line 510 contains
PRINT AT PI,21;" "; AT PI,30,— the trailing comma after30is unusual syntax; it may set a print position without printing anything, effectively just repositioning the cursor, which is harmless but redundant given the next iteration immediately overwrites that area. INis used as a variable name. While legal, it closely resembles the keywordINPUT(though the interpreter disambiguates by tokenization), and could cause confusion when reading the listing.- The
STOPat line 530 halts execution after the loop rather than returning to a menu or offering a restart, leaving the user at a break prompt. - Line 560 saves the program with
LINE 10, causing it to auto-run from line 10 on load.
Content
Source Code
10 BORDER 0:PAPER 0:INK 6:CLS
20 PRINT ' TAB 8;"LIFE TABLE"
30 PRINT '" THIS IS AN ACTUARIAL METHOD OF CALCULATING THE CUMULATIVE CHANCE OF AN EVENT USING STRICT RULES FOR THE STUDY."'" THERE MUST BE A CLEAR WELL DEFINED STARTING POINT."
40 PRINT " THERE MUST BE A CLEAR WELL DEFINED ENDPOINT."'" ITEMS CAN BE ENTERED AT "'"DIFFERENT TIMES AND CAN BE"'"OBSERVED FOR DIFFERENT LENGTHS OF TIME."'" AT THE END OF THE STUDY THE ENDPOINTS FOR SOME ENTRIES MAY BE UNKNOWN."
50 GO SUB 540
60 PRINT ''" LIFE TABLES ARE USED BY"'"INSURERS, BUSINESS, GOVERNMENTS AND HEALTH PROFESSIONS SO THAT COMPARISONS OF SURVIVAL, DEATHS,BUSINESS METHODS AND SUCCESS OF TREATMENTS CAN BE MADE."
70 PRINT '" USE CAPS LOCK."
80 PRINT '" 'NO EVENT' INCLUDES THOSE LOST, WITHDRAWN, OR THE TIME OF THE LAST REVIEW."
90 PRINT '" 'EVENT' COULD INCLUDE DEATH, THEN SURVIVAL MEANS NO EVENT."
100 GO SUB 540
110 PRINT AT 5, PI;"REMEMBER TO USE CAPS LOCK."
120 PRINT '" PREPARE YOUR DATA SO YOU KNOWTHE NUMBER OF SUBJECTS LOST OR DEAD FOR EACH TIME INTERVAL."
130 PRINT ''" LOST INCLUDES WITHDRAWN OR THE TIME OF THE LAST REVIEW."
140 PRINT ''" DEATH COULD INCLUDE AN EVENT.THEN SURVIVAL MEANS NO EVENT."
150 PRINT #0;"PRESS ANY KEY TO START"
160 PAUSE 0:CLS
170 INPUT "HOW MANY INTERVALS? ";IN
180 PRINT IN;" INTERVALS"
190 INPUT "HOW MANY ARE ENTERED? ";EN
200 PRINT ''EN;" ARE ENTERED"
210 GO SUB 540
220 CLS :PRINT "INTERVAL ENTERED LOST DEAD"
230 PRINT "-------- ------- ------ -----"
240 PRINT AT 7,0;"NUMBER PROPORTION PROPORTION"
250 PRINT "EXPOSED DEAD SURVIVING"
260 PRINT "------- ---------- ----------"
270 PRINT AT 15,0;"CUM.CHANCE CUM.CHANCE % CHANCE"
280 PRINT "SURVIVING OF DEATH OF DEATH"
290 PRINT "---------- ---------- --------"
300 INK 7
310 FOR N=1 TO IN
320 PRINT AT PI,0;N-1;" - ";N
330 IF N=1 THEN PRINT AT PI,12;EN
340 IF N>1 THEN LET EN=EN-L-D:PRINT AT PI,12;EN;" "
350 INPUT "HOW MANY WERE LOST? ";L
360 PRINT AT PI,21;L;" "
370 INPUT "HOW MANY DIED? ";D
380 PRINT AT PI,30;D,
390 LET EX=EN-L*.5
400 PRINT AT 11,0;EX;" "
410 LET PD= INT (((D/EX)+.0005)*1000)/1000
420 PRINT AT 11,12;PD;" "
430 LET PSN=1-PD
440 PRINT AT 11,26;PSN;" "
450 IF N=1 THEN LET pso=psn:PRINT AT 19,0;PSO
460 IF N=1 THEN PRINT AT 19,12;PD; AT 19,26;pd*100;"%"
470 IF N>1 THEN LET CCS= INT ((PSO*PSN+.0005)*1000)/1000
480 IF N>1 THEN LET pso=ccs:PRINT AT 19,0;CCS
490 IF N>1 THEN PRINT AT 19,12;1-ccs; AT 19,26;(1-CCS)*100;" "
500 INPUT "PRESS ANY KEY FOR THE NEXT INTERVAL ANALYSIS";Q$
510 PRINT AT PI,21;" "; AT PI,30,
520 NEXT N
530 STOP
540 PRINT #0;"PRESS ANY KEY TO CONTINUE ":PAUSE 0:CLS :RETURN
550 REM An original program by D.J. Currie - - -June 1985
560 SAVE "LIFE TABLE" LINE 10
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
