    * Rep_Survival 11 years sensitivity to time of censoring.sps.
    * Written by PSKL on 24/09/02 and truncated on 18/10/02.

    get file='D:\Longitudinal Data\Rep_Observed Restoration Lives 1991 to 2001.sav'.

    * Restrict to restorations placed before the end of the observation period 31/12/2001.

    select if (doplacn<yrmoda(2001,12,31)-yrmoda(1899,12,31)).

    * Check whether time is in acceptable range, and set reint flag.

    compute reint=0.
    if not (missing(time)) reint=1.
    if (time le 0) reint=0.
    if (doplacn+time>yrmoda(2001,12,31)-yrmoda(1899,12,31)) reint=0.

    execute.

    **************************************************************************************.

    * Double up the cases with no re-intervention and weight by probability of re-intervention.
    compute caseid=$casenum.
    execute.

    * Look up probability of reattendance after last visit.
    sort cases by interval.
    match files file=*
     /table='D:\Longitudinal Data\Rep_reattendance probability.sav'
     /by interval.
    compute recid=1.
    sort cases by caseid.
    save outfile='d:\temp1.sav'.

    select if (reint=0).
    compute recid=2.
    sort cases by caseid.
    save outfile='d:\temp2.sav'.

    add files file='d:\temp1.sav'
     /file='d:\temp2.sav'
     /by caseid .

    Compute weight = 1000.
    Do if (reint=0).
    if (recid=1) weight = 1000-trunc(1000*prreatt+0.5).
    if (recid=2) weight = trunc(1000*prreatt+0.5).
    end if.

    save outfile='d:\temp3.sav'.

    get file='d:\temp3.sav'.

    *******************************************************************************************.
    * Test 1 Assume censored cases are lost at one year (365 days) after last visit.

    * recalculate time if reint=0.
    * Impute effective time of censoring.
    Do if (reint=0).
    If (recid=1) time=min(lastvn+365,yrmoda(2001,12,31)-yrmoda(1899,12,31))- doplacn.
    if (recid=2) time=yrmoda(2001,12,31)-yrmoda(1899,12,31)- doplacn.
    end if.

    * Plot unadjusted KM, for confidence intervals

    temporary.
    * Censor all non-returners.
    select if (recid=1).

    KM
      time  /STATUS=reint(1)
      /PRINT MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:15:31
Comments |
Input | Data | d:\temp3.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 485400
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).
Resources | Elapsed Time | 0:00:48.01

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2498.92                2.89     (  2493.26,   2504.58 )
     (Limited to   4017.0 )
     Median:    2824.00               12.00     (  2800.48,   2847.52 )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3416.00      2824.00      2320.00      1519.00       941.00       710.00
     Standard Error        .            .            .            .          12.00         9.20         5.66         3.50         2.70

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              509.00       332.00       175.00
     Standard Error       2.04         1.47          .

    * Adjusted KM, but increased weights give incorrect confidence intervals.

    weight by weight.

    KM
      time  /STATUS=reint(1)
      /PRINT  MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95)
      /save Survival(surv1YR).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:16:19
Comments |
Input | Data | d:\temp3.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 814068
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95) /save Survival(surv1YR).
Resources | Elapsed Time | 0:02:07.72

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2553.18                 .09     (  2553.01,   2553.36 )
     (Limited to   4017.0 )
     Median:    3061.00                 .46     (  3060.09,   3061.91 )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3808.00      3061.00      2486.00      1593.00       967.00       723.00
     Standard Error        .            .            .            .            .46          .33          .19          .12          .09

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              515.00       332.00       175.00
     Standard Error        .07          .05          .

    >Warning # 3211
    >On at least one case, the value of the weight variable was zero, negative,
    >or missing.  Such cases are invisible to statistical procedures and graphs
    >which need positively weighted cases, but remain on the file and are
    >processed by non-statistical facilities such as LIST and SAVE.

    save outfile='D:\temp4.sav'.

    **************************************************************************************.

    * Test 2 Assume censored cases are lost on date of last visit.

    get file = 'D:\temp4.sav'.

    weight off.
    * recalculate time if reint=0.
    * Impute effective time of censoring.
    Do if (reint=0).
    If (recid=1) time=min(lastvn,yrmoda(2001,12,31)-yrmoda(1899,12,31))- doplacn.
    if (recid=2) time=yrmoda(2001,12,31)-yrmoda(1899,12,31)- doplacn.
    end if.

    * Plot unadjusted KM, for confidence intervals

    temporary.
    * Censor all non-returners.
    select if (recid=1).

    KM
      time  /STATUS=reint(1)
      /PRINT MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:19:17
Comments |
Input | Data | D:\temp4.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 485400
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).
Resources | Elapsed Time | 0:00:42.12

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2348.43                3.03     (  2342.49,   2354.37 )
     (Limited to   4017.0 )
     Median:    2406.00                9.38     (  2387.61,   2424.39 )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .        3912.00      2884.00      2406.00      1982.00      1308.00       805.00       607.00
     Standard Error        .            .            .          11.68         9.38         7.57         4.92         3.12         2.47

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              427.00       271.00       153.00
     Standard Error       1.93         1.29          .

    * Adjusted KM, but increased weights give incorrect confidence intervals.

    weight by weight.

    KM
      time  /STATUS=reint(1)
      /PRINT  MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95)
      /save Survival(surv0).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:19:59
Comments |
Input | Data | D:\temp4.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 814068
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95) /save Survival(surv0).
Resources | Elapsed Time | 0:02:01.19

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2474.75                 .09     (  2474.57,   2474.93 )
     (Limited to   4017.0 )
     Median:    2793.00                 .39     (  2792.23,   2793.77 )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3437.00      2793.00      2257.00      1446.00       876.00       652.00
     Standard Error        .            .            .            .            .39          .30          .18          .11          .08

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              456.00       290.00       161.00
     Standard Error        .06          .04          .

    >Warning # 3211
    >On at least one case, the value of the weight variable was zero, negative,
    >or missing.  Such cases are invisible to statistical procedures and graphs
    >which need positively weighted cases, but remain on the file and are
    >processed by non-statistical facilities such as LIST and SAVE.

    save outfile='D:\temp5.sav'.

    **************************************************************************************.

    * Test 3 Assume censored cases are lost at end of observation period (31/12/2001).

    get file = 'D:\temp5.sav'.

    weight off.
    * recalculate time if reint=0.
    * Impute effective time of censoring.

    If (reint=0) time=yrmoda(2001,12,31)-yrmoda(1899,12,31)- doplacn.

    * Plot unadjusted KM, for confidence intervals

    temporary.
    * Censor all non-returners.
    select if (recid=1).

    KM
      time  /STATUS=reint(1)
      /PRINT MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:22:51
Comments |
Input | Data | D:\temp5.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 485400
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).
Resources | Elapsed Time | 0:00:48.02

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2767.86                2.51     (  2762.93,   2772.79 )
     (Limited to   4017.0 )
     Median:        .                   .       (      .  ,       .   )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .            .            .        2043.00      1093.00       777.00
     Standard Error        .            .            .            .            .            .          10.33         4.73         3.35

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              534.00       332.00       175.00
     Standard Error       2.35         1.58          .

    * Adjusted KM, but increased weights give incorrect confidence intervals.

    weight by weight.

    KM
      time  /STATUS=reint(1)
      /PRINT  MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95)
      /save Survival(survend).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:23:39
Comments |
Input | Data | D:\temp5.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 814068
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95) /save Survival(survend).
Resources | Elapsed Time | 0:02:08.66

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2767.86                 .08     (  2767.70,   2768.01 )
     (Limited to   4017.0 )
     Median:        .                   .       (      .  ,       .   )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .            .            .        2043.00      1093.00       777.00
     Standard Error        .            .            .            .            .            .            .33          .15          .11

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              534.00       332.00       175.00
     Standard Error        .07          .05          .

    >Warning # 3211
    >On at least one case, the value of the weight variable was zero, negative,
    >or missing.  Such cases are invisible to statistical procedures and graphs
    >which need positively weighted cases, but remain on the file and are
    >processed by non-statistical facilities such as LIST and SAVE.

    save outfile='D:\temp6.sav'.

    **************************************************************************************.

    * Test 4 Assume censored cases are lost half way between date last seen and end of observation period (31/12/2001).

    get file = 'D:\temp6.sav'.

    weight off.

    * recalculate time if reint=0.
    * Impute effective time of censoring.

    Do if (reint=0).
    If (recid=1) time=(lastvn+yrmoda(2001,12,31)-yrmoda(1899,12,31))/2- doplacn.
    if (recid=2) time=yrmoda(2001,12,31)-yrmoda(1899,12,31)- doplacn.
    end if.

    * Plot unadjusted KM, for confidence intervals

    temporary.
    * Censor all non-returners.
    select if (recid=1).

    KM
      time  /STATUS=reint(1)
      /PRINT MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:26:40
Comments |
Input | Data | D:\temp6.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 485400
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95).
Resources | Elapsed Time | 0:00:51.95

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2619.48                2.83     (  2613.93,   2625.02 )
     (Limited to   4051.5 )
     Median:    3240.00               13.32     (  3213.89,   3266.11 )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3807.00      3240.00      2719.00      1783.00      1034.00       750.00
     Standard Error        .            .            .            .          13.32        10.36         6.85         4.20         3.12

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              520.00       326.00       173.00
     Standard Error       2.26         1.53          .

    * Adjusted KM, but increased weights give incorrect confidence intervals.

    weight by weight.

    KM
      time  /STATUS=reint(1)
      /PRINT  MEAN
      /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95)
      /save Survival(survhalf).

# Kaplan-Meier

Notes
Output Created | 28-MAY-2003 11:27:32
Comments |
Input | Data | D:\temp6.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 814068
Syntax | KM time /STATUS=reint(1) /PRINT MEAN /PERCENTILES = (25,30,35,45,50,55,65,75,80,85,90,95) /save Survival(survhalf).
Resources | Elapsed Time | 0:01:59.71

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2669.21                 .09     (  2669.04,   2669.38 )
     (Limited to   4051.5 )
     Median:    3520.00                 .       (      .  ,       .   )

                                                                   Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .        3520.00      2884.00      1854.00      1064.00       766.00
     Standard Error        .            .            .            .            .            .38          .23          .14          .10

                                                                   Percentiles

                         85.00        90.00        95.00

     Value              530.00       330.00       174.00
     Standard Error        .07          .05          .

    >Warning # 3211
    >On at least one case, the value of the weight variable was zero, negative,
    >or missing.  Such cases are invisible to statistical procedures and graphs
    >which need positively weighted cases, but remain on the file and are
    >processed by non-statistical facilities such as LIST and SAVE.

    save outfile='D:\temp7.sav'.

    **************************************************************************************.

    * Create an Excel file for charting.
    get file='d:\temp7.sav'.

    weight off.

    select if (reint=1).
    sort cases by time.
    aggregate outfile=*
     /presorted
     /break time
     / surv1yr surv0 survend survhalf
    = first( surv1yr surv0 survend survhalf).

    SAVE TRANSLATE OUTFILE='I:\Research Projects\longevity\Rep_1991 to 2001 sensitivity.xls'
      /TYPE=XLS /MAP /REPLACE /FIELDNAMES.

    Data written to I:\Research Projects\longevity\Rep_1991 to 2001 sensitivity.xls.
    5 variables and 3775 cases written to range: SPSS.
    Variable: TIME       Type: Number   Width:  8   Dec: 2
    Variable: SURV1YR    Type: Number   Width: 10   Dec: 5
    Variable: SURV0      Type: Number   Width: 10   Dec: 5
    Variable: SURVEND    Type: Number   Width: 10   Dec: 5
    Variable: SURVHALF   Type: Number   Width: 10   Dec: 5