*************************************************************; * Life table data for 2418 males and 555 females after reporting * symptoms of angina pectoris. * * Column headings in datalines block: * year (after diagnosis) * male (deaths, censored) female (deaths, censored) * * The command `output' tells SAS to write a record using the current * variables. If there are no `output' commands in a data step, then * SAS, in effect, supplies an `output' command at the end of the * data step. If you say `output' anywhere within a data step, then * SAS writes a record ONLY when you say `output'. (This gives you * greater control about when and if you write data records.) * * SAS determines the length of a text variable from the first time * that text is stored in it. If sex='Male ' below were replaced * by sex='Male', then 'Female' would be truncated to 'Fema' in * much of the output. * * The data step writes 4 records for each line from the datalines * block. These records have variables * * year(time), sex, number, status (death=0, censored=1) * * as well as a number of scratch (unused) other variables. * * Sources of data: * E.T.Lee and J.W.Wang, ``Statistical analysis for survival data * analysis'', 3rd edition. * Males: page 92, Table 4.7 * Females: page 104, Exercise Table 4.2 *************************************************************; title 'Survival of two sexes with angina pectoris - YOUR NAME'; title2 'Males and females diagnosed with angina pectoris (Lee+Wang p92,p104)'; options ls=75 ps=60 pageno=1 nocenter; data ltangina; input year mdeaths mcens fdeaths fcens; year=year-0.5; * Adjust to time-interval midpoint; sex='Male '; num=mdeaths; status=0; output; num=mcens; status=1; output; sex='Female'; num=fdeaths; status=0; output; num=fcens; status=1; output; datalines; 1 456 0 82 0 2 226 39 30 8 3 152 22 27 8 4 171 23 22 7 5 135 24 26 7 6 125 107 25 28 7 83 133 20 31 8 74 102 11 32 9 51 68 14 24 10 42 64 13 27 11 43 45 5 22 12 34 53 5 23 13 18 33 5 18 14 9 27 2 9 15 6 23 3 7 16 0 0 3 11 17 0 30 0 0 ; proc print; title3 'The data as SAS sees it:'; run; *************************************************************; * In `proc lifetest' below, `plots=(s,ls,lls,h)' tells SAS to * write 4 plots: * s=S(t), ls=-log S(t), lls=log (-log S(t)), and h=h(t) * where S(t) is the survival function and h(t) is the hazard * function. * * If the data within each sex is exponentially distributed, then * the ls curve(s) will be linear and the hazard curves will be * constant. If the data within each sex is Weibull distributed, * then the lls curve(s) will be linear. * * If `sex' acts on survival with a constant (proportional) ratio * of hazards, then the two lls curves will be parallel. * * The `freq' command tells SAS how many people are involved for * that year and censoring status. * * The option `method=act' says to use standard actuarial corrections * to estimate hazard rates and survival functions. The option * `intervals=...' tells SAS to group data using those intervals. * This is necessary to use the actuarial method. If you enter * `method=act' and specify intervals, SAS will include actuarial * tables in the output unless you also enter `notable'. * * `Effective Sample Size' in the first table in the output is the * number surviving at the beginning of that year minus half the * number censored that year, which is used in the actuarial * correction. The next column (``Conditional Probability of * Failure'') is the number of deaths divided by this effective * sample size. This is the actuarial hazard correction to the * survival function for that interval, as opposed to the estimated * hazard RATE for that interval. * * The hazard RATE --- the number of deaths divided by the number * alive at the beginning of the interval minus half the number * of censorings AND deaths --- appears in the third table in the * output under the column heading ``Hazard''. See the handout * ``Actuarial Estimates for Life Tables'' on the Math434 Web site * for a discussion of hazard RATE and the hazard CORRECTION and * why there is a difference. * * The numbers under ``Survival'' in the second table are the * Kaplan-Meier-like survival function values for the * actuarial correction. * *************************************************************; proc lifetest plots=(s,ls,lls,h) intervals=(0 to 15 by 1) method=act lineprinter; title3 'Actuarial tables and graphs'; strata sex; time year*status(1); freq num; run;