    * 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\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\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 | 19-NOV-2002 12:00:49
Comments |
Input | Data | d:\temp3.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 503965
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.39

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2483.62                2.83     (  2478.07,   2489.17 )
     (Limited to   4016.0 )
     Median:    2766.00               11.51     (  2743.43,   2788.57 )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3362.00      2766.00      2276.00      1495.00       924.00       696.00
     Standard Error        .            .            .            .          11.51         8.73         5.45         3.36         2.62

                                                                Percentiles

                         85.00        90.00        95.00

     Value              496.00       321.00       168.00
     Standard Error       1.99         1.40          .

    * 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 | 19-NOV-2002 12:01:40
Comments |
Input | Data | d:\temp3.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 843599
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:01:47.80

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2537.38                 .09     (  2537.21,   2537.55 )
     (Limited to   4016.0 )
     Median:    3003.00                 .45     (  3002.12,   3003.88 )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3761.00      3003.00      2430.00      1562.00       949.00       709.00
     Standard Error        .            .            .            .            .45          .31          .19          .11          .09

                                                                Percentiles

                         85.00        90.00        95.00

     Value              500.00       321.00       168.00
     Standard Error        .06          .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 | 19-NOV-2002 12:04:15
Comments |
Input | Data | D:\temp4.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 503965
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:50.19

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2332.63                2.97     (  2326.81,   2338.45 )
     (Limited to   4016.0 )
     Median:    2352.00                8.86     (  2334.64,   2369.36 )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .        3924.00      2827.00      2352.00      1952.00      1282.00       792.00       593.00
     Standard Error        .            .            .          11.38         8.86         7.19         4.70         3.02         2.42

                                                                Percentiles

                         85.00        90.00        95.00

     Value              414.00       261.00       147.00
     Standard Error       1.86         1.24          .

    * 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 | 19-NOV-2002 12:05:05
Comments |
Input | Data | D:\temp4.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 843599
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:01:51.19

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2458.31                 .09     (  2458.13,   2458.48 )
     (Limited to   4016.0 )
     Median:    2727.00                 .38     (  2726.26,   2727.74 )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3375.00      2727.00      2212.00      1420.00       861.00       637.00
     Standard Error        .            .            .            .            .38          .28          .17          .10          .08

                                                                Percentiles

                         85.00        90.00        95.00

     Value              443.00       280.00       155.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 | 19-NOV-2002 12:07:42
Comments |
Input | Data | D:\temp5.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 503965
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:47.19

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2752.33                2.47     (  2747.49,   2757.18 )
     (Limited to   4016.0 )
     Median:        .                   .       (      .  ,       .   )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .            .            .        1994.00      1064.00       761.00
     Standard Error        .            .            .            .            .            .           9.72         4.52         3.21

                                                                Percentiles

                         85.00        90.00        95.00

     Value              518.00       321.00       168.00
     Standard Error       2.28         1.50          .

    * 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 | 19-NOV-2002 12:08:29
Comments |
Input | Data | D:\temp5.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 843599
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:01:59.15

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2752.33                 .08     (  2752.18,   2752.49 )
     (Limited to   4016.0 )
     Median:        .                   .       (      .  ,       .   )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .            .            .        1994.00      1064.00       761.00
     Standard Error        .            .            .            .            .            .            .31          .14          .10

                                                                Percentiles

                         85.00        90.00        95.00

     Value              518.00       321.00       168.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 | 19-NOV-2002 12:11:16
Comments |
Input | Data | D:\temp6.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 503965
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.87

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2605.27                2.78     (  2599.83,   2610.71 )
     (Limited to   4051.0 )
     Median:    3183.00               13.15     (  3157.23,   3208.77 )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .        3779.00      3183.00      2659.00      1750.00      1009.00       735.00
     Standard Error        .            .            .            .          13.15         9.84         6.60         4.03         3.01

                                                                Percentiles

                         85.00        90.00        95.00

     Value              505.00       315.00       168.00
     Standard Error       2.19         1.46          .

    * 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 | 19-NOV-2002 12:12:05
Comments |
Input | Data | D:\temp6.sav
Filter | <none>
Weight | WEIGHT
Split File | <none>
N of Rows in Working Data File | 843599
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:02:22.69

     Survival Analysis for TIME

              Survival Time    Standard Error   95% Confidence Interval

     Mean:      2654.50                 .09     (  2654.33,   2654.67 )
     (Limited to   4051.0 )
     Median:    3475.00                 .       (      .  ,       .   )

                                                                Percentiles

                         25.00        30.00        35.00        45.00        50.00        55.00        65.00        75.00        80.00

     Value                 .            .            .            .        3475.00      2825.00      1819.00      1036.00       749.00
     Standard Error        .            .            .            .            .            .37          .22          .13          .10

                                                                Percentiles

                         85.00        90.00        95.00

     Value              514.00       319.00       168.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\1991 to 2001 sensitivity.xls'
      /TYPE=XLS /MAP /REPLACE /FIELDNAMES.

    Data written to I:\Research Projects\longevity\1991 to 2001 sensitivity.xls.
    5 variables and 3783 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