27
EHEMU Technical report 2007_6 June 2007 The SAS and SPSS programmes for calculating health expectancies Report written by Bianca Cox

The SAS and SPSS programmes for calculating health ...ec.europa.eu/health/ph_projects/2003/action1/docs/2003_1_08_tc... · The SAS and SPSS programmes for calculating health expectancies

  • Upload
    vomien

  • View
    237

  • Download
    0

Embed Size (px)

Citation preview

EHEMU Technical report 2007_6 June 2007

The SAS and SPSS programmes for calculating health expectancies

Report written by Bianca Cox

1

The EHEMU team comprises:

Jean-Marie Robine, Health and Demography, Université de Montpellier, France,

[email protected]

Carol Jagger, University of Leicester, United-Kingdom, [email protected]

Herman van Oyen, Scientific Institute of Public Health, Belgium, [email protected]

Emmanuelle Cambois, INED (Institut National d’Etudes Démographiques), France, [email protected]

Bianca Cox, Scientific Institute of Public Health, Belgium, [email protected]

Isabelle Romieu, Health and Demography, Université de Montpellier, France,

[email protected]

Aurore Clavel, Health and Demography, Université de Montpellier, France,

[email protected]

Sophie Le Roy, Health and Demography, Université de Montpellier, France, [email protected]

Contact EHEMU: Isabelle Romieu Equipe Démographie et Santé, Centre Val d'Aurelle, Parc Euromédecine, 34298 Montpellier cedex 5, France. Tel: +33 (0) 467 61 30 27 Fax: +33 (0) 467 61 37 87 Email: [email protected]

2

SAS and SPSS programs for calculating health expectancies In addition to the Excel spreadsheet, SAS and SPSS programs are provided for calculating health

expectancies. The programs contain the examples presented in the Calculation Guide. Both programs

are provided in text form (Word document) so that they can also be viewed by users who don’t have

SAS or SPSS software. In order to use the program, select the text from the Word document and copy

it into the command window of the corresponding software (named “Editor” in SAS and “Syntax” in

SPSS).

The input data needed for both programs are provided in the Excel files: input_examples.xls. In the

SAS and SPSS programs, you only need to change the name of the directory in which the input and

output datasets are stored. After running the program, eight output datasets are produced: example1,

example2, example3, example4A, example4B, example5, example6A and example6B. The

extensions of these datasets are .sas7bdat for SAS and .sav for SPSS. The programs can also be

used on other data, provided that the input data are supplied in the same format.

3

Excel spreadsheets Input_example1:

x Px Dx Px1 Dx2 B pix 0 54795,5 202 54934 170 56189 0 1 54818 21 0,048 2 55665,5 11 0,048 3 55969,5 8 0,048 4 55805,5 12 0,048 5 56401,5 8 0,03 6 57484,5 6 0,03 7 58296,5 11 0,03 8 58676,5 5 0,03 9 59682 6 0,03

10 61938,5 2 0,072 11 63185 5 0,072 12 63177 13 0,072 13 61984,5 9 0,072 14 60475 9 0,072 15 59806 10 0,098 16 58949,5 10 0,098 17 59076 12 0,098 18 59094,5 23 0,098 19 60558,5 24 0,098 20 61594,5 14 0,087 21 62947,5 27 0,087 22 64011 23 0,087 23 64035,5 24 0,087 24 62941,5 16 0,087 25 63049,5 20 0,096 26 63079,5 25 0,096 27 63313 30 0,096 28 63587,5 21 0,096 29 66030 25 0,096 30 67970 29 0,089 31 70468 30 0,089 32 72499 24 0,089 33 73138,5 37 0,089 34 73895,5 44 0,089 35 74710 52 0,142 36 76245,5 61 0,142 37 79016,5 61 0,142 38 80763 60 0,142 39 82647,5 79 0,142 40 81702 82 0,122 41 80813 103 0,122 42 81101 96 0,122 43 80078,5 104 0,122 44 80162 114 0,122 45 78173 123 0,195 46 76508 132 0,195 47 75315 167 0,195 48 73965,5 146 0,195 49 73183,5 196 0,195 50 72064,5 199 0,161 51 71936,5 229 0,161

4

52 71115,5 264 0,161 53 71959 287 0,161 54 70745,5 285 0,161 55 69591 307 0,298 56 66630 285 0,298 57 64055 261 0,298 58 56176,5 236 0,298 59 54783 234 0,298 60 51870 264 0,234 61 47611,5 301 0,234 62 46013 328 0,234 63 50033 351 0,234 64 52686 366 0,234 65 53073 365 0,257 66 51635,5 468 0,257 67 51718,5 495 0,257 68 51932,5 580 0,257 69 52759,5 692 0,257 70 52804 738 0,345 71 53988,5 809 0,345 72 53496,5 840 0,345 73 52671,5 944 0,345 74 49530,5 1059 0,345 75 49546,5 1161 0,431 76 49715 1532 0,431 77 49928 1887 0,431 78 48534,5 2042 0,431 79 45249 2121 0,431 80 41393,5 2049 0,431 81 36644 1765 0,431 82 32714 1435 0,431 83 28395 1038 0,431 84 20277,5 1201 0,431 85 125152 23298 0,513

Input_example4:

agegr Nx 0 52 1 230 5 257

10 275 15 281 20 342 25 402 30 426 35 437 40 446 45 438 50 424 55 407 60 310 65 398 70 413 75 310 80 300 85 647

5

Input_example5: agegr DFLEf S_DFLEf DFLEm S_DFLEm

0 66,5 0,36 63,5 0,33 1 65,8 0,36 62,7 0,33 5 62,0 0,35 58,9 0,33

10 57,2 0,35 54,2 0,32 15 52,6 0,34 49,6 0,32 20 48,2 0,33 45,0 0,31 25 43,7 0,32 40,5 0,31 30 39,2 0,31 36,0 0,30 35 34,8 0,31 31,7 0,29 40 30,6 0,29 27,5 0,28 45 26,4 0,29 23,8 0,27 50 22,6 0,27 20,1 0,26 55 18,8 0,26 16,9 0,24 60 15,6 0,24 13,5 0,23 65 12,3 0,22 10,6 0,21 70 9,1 0,20 7,8 0,20 75 6,5 0,18 5,4 0,19 80 4,6 0,15 3,9 0,18 85 2,6 0,11 2,6 0,16

Input_example6: agegr Ix

0 0 1 0 5 0

10 0 15 0 20 0 25 0,001 30 0,001 35 0,001 40 0,002 45 0,002 50 0,003 55 0,003 60 0,006 65 0,009 70 0,019 75 0,047 80 0,11 85 0,297

6

SAS Program

LIBNAME Sullivan "_____"; /* Specify the directory where you want to save the output data */ /*************************************************************************/ /* SULLIVAN HEALTH EXPECTANCY USING AN UNABRIDGED LIFE TABLE: EXAMPLE 1 */ /*************************************************************************/

/******** Calculation of the life table and life expectancy ********/ PROC IMPORT OUT= WORK.input_example1 DATAFILE= "_____\input_examples.xls" /* Specify the directory of the input data */ DBMS=EXCEL REPLACE; SHEET="input_example1$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; DATA example1; RETAIN x Px Dx mx qx rx pix; SET input_example1; mx=Dx/Px; qx=mx/(1+(0.5*mx)); IF x=0 THEN qx=1-(1-((Dx-Dx2)/Px1))*(1-(Dx2/B)); IF x=85 THEN qx=.; rx=1-qx; DROP Px1 Dx2 B; FORMAT Dx 6.0 Px 8.1 pix 5.3 mx qx rx 8.6; RUN; PROC EXPAND DATA=example1 OUT=example1 (DROP=time) METHOD=NONE; CONVERT rx=rxrx / TRANSFORM=(PRODUCT); RUN; DATA example1; RETAIN x Px Dx mx qx lx pix; SET example1; lagrxrx=LAG(rxrx); IF x=0 THEN lx=100000; ELSE lx=100000*lagrxrx; DROP rx rxrx lagrxrx; FORMAT lx 9.2; RUN; PROC SORT DATA=example1 OUT=example1; BY DESCENDING x; RUN; DATA example1; RETAIN x Px Dx mx qx lx LLx pix; SET example1; laglx=LAG(lx); LLx=(lx+laglx)/2; IF x=0 THEN LLx=0.2*lx+0.8*laglx; IF x=85 THEN LLx=lx/mx; DROP laglx; FORMAT Llx 10.2; RUN; PROC EXPAND DATA=example1 OUT=example1 (DROP=time) METHOD=NONE; CONVERT LLx=Tx / TRANSFORM=(SUM); RUN; PROC SORT DATA=example1 OUT=example1; BY x; RUN;

7

DATA example1; RETAIN x Px Dx mx qx lx LLx Tx ex pix; SET example1; ex=Tx/lx; FORMAT ex 4.1; RUN; /******** Calculation of Disability-Free Life Expectancy (DFLE) ********/

DATA example1; SET example1; LLx_disafr=LLx*(1-pix); FORMAT LLx_disafr 10.2; RUN; PROC SORT DATA=example1 OUT=example1; BY DESCENDING x; RUN; PROC EXPAND DATA=example1 OUT=example1 (DROP=time) METHOD=NONE; CONVERT LLx_disafr=Tx_disafr / TRANSFORM=(SUM); RUN; PROC SORT DATA=example1 OUT=example1; BY x; RUN; DATA example1; RETAIN x Px Dx mx qx lx LLx Tx ex pix LLx_disafr Tx_disafr DFLEx percDFLEx; SET example1; DFLEx=Tx_disafr/lx; percDFLEx=100*(DFLEx/ex); FORMAT DFLEx percDFLEx 4.1 ; RUN; DATA Sullivan.example1; SET example1; LABEL x='Age' Px='Mid-year population' Dx='No. deaths' mx='Central Death rate' qx='Conditional probability of death' lx='Numbers surviving to age x' LLx='Person years lived at age x' Tx='Total number of years lived from age x' ex='Total life Expectancy' pix='Proportion with disability' LLx_disafr='Person years lived without disability at age x' Tx_disafr='Total years lived without disability from age x' DFLEx='Disability-free life expectancy' percDFLEx='Proportion of life spent disability-free'; RUN; /*************************************************************************/ /*SULLIVAN HEALTH EXPECTANCY USING AN UNABRIDGED LIFE TABLE : EXAMPLE 2 */ /*************************************************************************/

/******** Calculation of the life table and life expectancy ********/ PROC FORMAT library=work; VALUE agegr 0='0' 1='1-4' 5='5-9' 10='10-14' 15='15-19' 20='20-24' 25='25-29' 30='30-34' 35='35-39' 40='40-44' 45='45-49' 50='50-54' 55='55-59' 60='60-64' 65='65-69' 70='70-74' 75='75-79' 80='80-84' 85='85+'; RUN;

8

DATA input_example2; RETAIN x agegr lx LLx pix; SET example1; FORMAT agegr agegr.; IF x=0 THEN agegr=0; IF (x ge 1 and x le 4) THEN agegr=1; IF (x ge 5 and x le 9) THEN agegr=5; IF (x ge 10 and x le 14) THEN agegr=10; IF (x ge 15 and x le 19) THEN agegr=15; IF (x ge 20 and x le 24) THEN agegr=20; IF (x ge 25 and x le 29) THEN agegr=25; IF (x ge 30 and x le 34) THEN agegr=30; IF (x ge 35 and x le 39) THEN agegr=35; IF (x ge 40 and x le 44) THEN agegr=40; IF (x ge 45 and x le 49) THEN agegr=45; IF (x ge 50 and x le 54) THEN agegr=50; IF (x ge 55 and x le 59) THEN agegr=55; IF (x ge 60 and x le 64) THEN agegr=60; IF (x ge 65 and x le 69) THEN agegr=65; IF (x ge 70 and x le 74) THEN agegr=70; IF (x ge 75 and x le 79) THEN agegr=75; IF (x ge 80 and x le 84) THEN agegr=80; IF (x ge 85) THEN agegr=85; KEEP x agegr lx LLx pix; RUN; PROC MEANS DATA=input_example2 IDMIN SUM; VAR LLx; BY agegr; ID x lx pix; OUTPUT OUT=example2 (DROP=_type_ _freq_) SUM(LLx)=nLx; RUN; PROC SORT DATA=example2 OUT=example2; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example2 OUT=example2 (DROP=time) METHOD=NONE; CONVERT nLx=Tx / TRANSFORM=(SUM); RUN; PROC SORT DATA=example2 OUT=example2; BY agegr; RUN; DATA example2; RETAIN x agegr lx nLx Tx ex pix; SET example2; ex=Tx/lx; FORMAT ex 4.1; RUN; /******** Calculation of Disability-Free Life Expectancy (DFLE) ********/

DATA example2; SET example2; nLx_disafr=nLx*(1-pix); FORMAT nLx_disafr 10.2; RUN; PROC SORT DATA=example2 OUT=example2; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example2 OUT=example2 (DROP=time) METHOD=NONE; CONVERT nLx_disafr=Tx_disafr / TRANSFORM=(SUM); RUN; PROC SORT DATA=example2 OUT=example2; BY agegr;

9

RUN; DATA example2; RETAIN x agegr lx nLx Tx ex pix nLx_disafr Tx_disafr DFLEx percDFLEx; SET example2; DFLEx=Tx_disafr/lx; percDFLEx=100*(DFLEx/ex); FORMAT DFLEx percDFLEx 4.1 ; RUN; DATA Sullivan.example2; RETAIN x agegroup lx nLx Tx ex pix nLx_disafr Tx_disafr DFLEx percDFLEx; SET example2; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' lx='Numbers surviving to age x' nLx='Person years lived in age interval' Tx='Total number of years lived from age x' ex='Total life Expectancy' pix='Proportion with disability' nLx_disafr='Person years lived without disability in age interval' Tx_disafr='Total years lived without disability from age x' DFLEx='Disability-free life expectancy' percDFLEx='Proportion of life spent disability-free'; RUN; /*************************************************************************/ /* SULLIVAN HEALTH EXPECTANCY USING AN ABRIDGED LIFE TABLE : EXAMPLE 3 */

/*************************************************************************/

/******** Calculation of the life table and life expectancy ********/ DATA input_example3; RETAIN x agegr Px Dx Px1 Dx2 B pix; SET input_example1; FORMAT agegr agegr. Px 8.1 Dx 6.0 pix 5.3 ; IF x=0 THEN agegr=0; IF (x ge 1 and x le 4) THEN agegr=1; IF (x ge 5 and x le 9) THEN agegr=5; IF (x ge 10 and x le 14) THEN agegr=10; IF (x ge 15 and x le 19) THEN agegr=15; IF (x ge 20 and x le 24) THEN agegr=20; IF (x ge 25 and x le 29) THEN agegr=25; IF (x ge 30 and x le 34) THEN agegr=30; IF (x ge 35 and x le 39) THEN agegr=35; IF (x ge 40 and x le 44) THEN agegr=40; IF (x ge 45 and x le 49) THEN agegr=45; IF (x ge 50 and x le 54) THEN agegr=50;

10

IF (x ge 55 and x le 59) THEN agegr=55; IF (x ge 60 and x le 64) THEN agegr=60; IF (x ge 65 and x le 69) THEN agegr=65; IF (x ge 70 and x le 74) THEN agegr=70; IF (x ge 75 and x le 79) THEN agegr=75; IF (x ge 80 and x le 84) THEN agegr=80; IF (x ge 85) THEN agegr=85; RUN; PROC MEANS DATA=input_example3 IDMIN SUM; VAR Px Dx; BY agegr; ID x Px1 Dx2 B pix; OUTPUT OUT=example3 (DROP=_type_ _freq_) SUM(Px)=Px SUM(Dx)=Dx; RUN; DATA example3; RETAIN x agegr Px Dx nmx ax nqx nrx pix; SET example3; nmx=Dx/Px; ax=0.5; nqx=(5*nmx)/(1+((1-ax)*5*nmx)); IF agegr=0 THEN nqx=1-(1-((Dx-Dx2)/Px1))*(1-(Dx2/B)); IF agegr=1 THEN nqx=(4*nmx)/(1+((1-ax)*4*nmx)); IF agegr=85 THEN nqx=.; nrx=1-nqx; DROP Dx2 Px1 B; FORMAT nmx 8.6 nqx 10.8; RUN; PROC EXPAND DATA=example3 OUT=example3 (DROP=time) METHOD=NONE; CONVERT nrx=nrxrx / TRANSFORM=(PRODUCT); RUN; DATA example3; RETAIN x agegr Px Dx nmx ax nqx lx pix; SET example3; lagnrxrx=LAG(nrxrx); IF agegr=0 THEN lx=100000; ELSE lx=100000*lagnrxrx; DROP nrx nrxrx lagnrxrx; FORMAT lx 8.1; RUN; PROC SORT DATA=example3 OUT=example3; BY DESCENDING agegr; RUN; DATA example3; RETAIN x agegr Px Dx nmx ax nqx lx nLx pix; SET example3; laglx=LAG(lx); nLx=((lx*5*ax)+(laglx*5*(1-ax))); IF agegr=0 THEN nLx=((lx*0.2)+(laglx*0.8)); IF agegr=1 THEN nLx=((lx*4*ax)+(laglx*4*(1-ax))); IF agegr=85 THEN nLx=lx/nmx; DROP laglx; FORMAT nLx 9.1; RUN; PROC EXPAND DATA=example3 OUT=example3 (DROP=time) METHOD=NONE; CONVERT nLx=Tx / TRANSFORM=(SUM); RUN; PROC SORT DATA=example3 OUT=example3; BY agegr; RUN; DATA example3; RETAIN x agegr Px Dx nmx ax nqx lx nLx Tx ex pix; SET example3;

11

ex=Tx/lx; FORMAT ex 4.1; RUN; /******** Calculation of Disability-Free Life Expectancy (DFLE) ********/

DATA example3; SET example3; nLx_disafr=nLx*(1-pix); FORMAT nLx_disafr 9.1; RUN; PROC SORT DATA=example3 OUT=example3; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example3 OUT=example3 (DROP=time) METHOD=NONE; CONVERT nLx_disafr=Tx_disafr / TRANSFORM=(SUM); RUN; PROC SORT DATA=example3 OUT=example3; BY agegr; RUN; DATA example3; RETAIN x agegr Px Dx nmx ax nqx lx nLx Tx ex pix nLx_disafr Tx_disafr DFLEx percDFLEx; SET example3; DFLEx=Tx_disafr/lx; percDFLEx=100*(DFLEx/ex); FORMAT DFLEx percDFLEx 4.1 ; RUN; DATA Sullivan.example3; RETAIN x agegroup Px Dx nmx ax nqx lx nLx Tx ex pix nLx_disafr Tx_disafr DFLEx percDFLEx; SET example3; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' Px='Mid-year population' Dx='No. deaths' nmx='Central Death rate' nqx='Conditional probability of death in age interval' lx='Numbers surviving to age x' nLx='Person years lived in age interval' Tx='Total number of years lived from age x' ex='Total life Expectancy' pix='Proportion with disability' nLx_disafr='Person years lived without disability in age interval' Tx_disafr='Total years lived without disability from age x' DFLEx='Disability-free life expectancy' percDFLEx='Proportion of life spent disability-free';

12

RUN; /*************************************************************************/

/*THE STANDARD ERROR OF THE SULLIVAN HEALTH EXPECTANCY: EXAMPLE 4 */ /*************************************************************************/ /Approximate standard errors ignoring the variance of the mortality rates / PROC IMPORT OUT= WORK.input_example4 DATAFILE= "_____\input_examples.xls" /* Specify the directory of the input data */ DBMS=EXCEL REPLACE; SHEET="input_example4$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; DATA example4A; RETAIN x agegr ax Dx nqx lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix; merge example3 input_example4; BY agegr; S2_pix=(pix*(1-pix))/Nx; L2S2_pix=(nLx**2)*S2_pix; KEEP x agegr ax Dx nqx lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix; FORMAT S2_pix 8.6 L2S2_pix 9.0; RUN; PROC SORT DATA=example4A OUT=example4A; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example4A OUT=example4A (DROP=time) METHOD=NONE; CONVERT L2S2_pix=T_L2S2_pix/TRANSFORM=(SUM); RUN; PROC SORT DATA=example4A OUT=example4A; BY agegr; RUN; DATA example4A; RETAIN x agegr ax Dx nqx lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix T_L2S2_pix S2_DFLEx S_DFLEx; SET example4A; S2_DFLEx=T_L2S2_pix/(lx**2); S_DFLEx=sqrt(S2_DFLEx); FORMAT S2_pix 8.6 L2S2_pix T_L2S2_pix 10.0 S2_DFLEx 7.5 S_DFLEx 5.3; RUN; DATA Sullivan.example4A; RETAIN x agegroup lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix T_L2S2_pix S2_DFLEx S_DFLEx; SET example4A; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64';

13

IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' Dx='No. deaths' nqx='Conditional probability of death in age interval' lx='Numbers surviving to age x' nLx='Person years lived in age interval' ex='Total life Expectancy' pix='Proportion with disability' nLx_disafr='Person years lived without disability in age interval' Tx_disafr='Total years lived without disability from age x' DFLEx='Disability-free life expectancy' Nx='Number in survey in age interval' S2_pix='Variance of prevalence disability-free' S2_DFLEx='Variance of DFLEx' S_DFLEx='Standard error of DFLEx'; KEEP x agegroup lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix T_L2S2_pix S2_DFLEx S_DFLEx; RUN; / Standard errors taking into account the variance of the mortality rates / DATA example4B; SET example4A; S2_DFLEx_1=S2_DFLEx; S2_qx=((nqx**2)*(1-nqx))/Dx; IF agegr=85 THEN S2_qx=0; KEEP x agegr ax Dx nqx lx pix DFLEx S2_DFLEx_1 S2_qx; FORMAT S2_DFLEx_1 7.5 S2_qx 10.8; RUN; PROC SORT DATA=example4B OUT=example4B; BY DESCENDING agegr; RUN; DATA example4B; SET example4B; lagDFLEx=LAG(DFLEx); RUN; PROC SORT DATA=example4B OUT=example4B; BY agegr; RUN; DATA example4B; SET example4B; y=(((1-ax)*5*(1-pix))+lagDFLEx); IF agegr=0 THEN y=(((1-ax)*(1-pix))+lagDFLEx); IF agegr=1 THEN y=(((1-ax)*4*(1-pix))+lagDFLEx); IF agegr=85 THEN y=0; z=((y**2)*(lx**2)*(S2_qx)); DROP lagDFLEx; FORMAT y 7.4 z 12.3; RUN; PROC SORT DATA=example4B; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example4B OUT=example4B (DROP=time) METHOD=NONE; CONVERT z=T_z / TRANSFORM=(SUM); RUN; PROC SORT DATA=example4B OUT=example4B; BY agegr; RUN;

14

DATA example4B; RETAIN x agegr ax Dx nqx lx pix DFLEx S2_DFLEx_1 S2_qx y z T_z S2_DFLEx_2 S2_DFLEx; SET example4B; S2_DFLEx_2=T_z/(lx**2); S2_DFLEx=S2_DFLEx_1+S2_DFLEx_2; FORMAT S2_DFLEx_2 S2_DFLEx 7.5; RUN; DATA Sullivan.example4B; RETAIN x agegroup ax Dx nqx lx pix DFLEx S2_DFLEx_1 S2_qx y z T_z S2_DFLEx_2 S2_DFLEx; SET example4B; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' Dx='No. deaths' nqx='Conditional probability of death in age interval' lx='Numbers surviving to age x' pix='Proportion with disability' DFLEx='Disability-free life expectancy' S2_qx='Variance of probability of death' S2_DFLEx_1='Variance of DFLEx (due to prevalence)' S2_DFLEx_2='Variance of DFLEx (due to mortality)' S2_DFLEx='Total variance of DFLEx'; RUN; /*************************************************************************/ /*TESTING THE EQUALITY OF TWO SULLIVAN HEALTH EXPECTANCIES : EXAMPLE 5 */

/*************************************************************************/ PROC IMPORT OUT= WORK.input_example5 DATAFILE= "_____\input_examples.xls" /* Specify the directory of the input data */ DBMS=EXCEL REPLACE; SHEET="input_example5$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; DATA example5; RETAIN x agegr DFLEf S_DFLEf DFLEm S_DFLEm diff_DFLE S_diff_DFLE z p; SET input_example5; x=agegr; diff_DFLE=DFLEf-DFLEm; S_diff_DFLE=S_DFLEf+S_DFLEm; z=diff_DFLE/S_diff_DFLE; pvalue=2*(1-cdf('NORMAL',z)); length p $ 7; IF pvalue>0.20 THEN p='>0.20';

15

IF pvalue<0.20 THEN p='<0.20'; IF pvalue<0.10 THEN p='<0.10'; IF pvalue<0.05 THEN p='<0.05'; IF pvalue<0.02 THEN p='<0.02'; IF pvalue<0.01 THEN p='<0.01'; IF pvalue<0.002 THEN p='<0.002'; IF pvalue<0.001 THEN p='<0.001'; DROP pvalue; FORMAT agegr agegr. DFLEf DFLEm 4.1 S_DFLEf S_DFLEm diff_DFLE S_diff_DFLE z 4.2; RUN; DATA Sullivan.example5; RETAIN x agegroup DFLEf S_DFLEf DFLEm S_DFLEm diff_DFLE S_diff_DFLE z p; SET example5; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' DFLEf='Disability-free life expectancy females' S_DFLEf='Standard error of DFLE females' DFLEm='Disability-free life expectancy males' S_DFLEm='Standard error of DFLE males' diff_DFLE='Difference in DFLE between males and females' S_diff_DFLE='Approximate standard error of difference in DFLE between males and females' z='z statistic' p='p value'; RUN; /*************************************************************************/

/** SULLIVAN HEALTH EXPECTANCY USING SEPARATE DATA SOURCES FOR INSTITUTIONALISED: EXAMPLE 6 **/

/*************************************************************************/ /******** Calculation of Disability-Free Life Expectancy (DFLE) ********/

PROC IMPORT OUT= WORK.input_example6 DATAFILE= "_____\input_examples.xls" /* Specify the directory of the input data */ DBMS=EXCEL REPLACE; SHEET="input_example6$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; DATA example6A; RETAIN x agegr lx nLx ex pix Ix pix_total nLx_disafr_total DFLEx; merge input_example6 example3; pix_total=((1-Ix)*(pix))+Ix; nLx_disafr_total=nLx*(1-pix_total);

16

KEEP x agegr lx nLx ex pix Ix pix_total nLx_disafr_total DFLEx; FORMAT Ix pix_total 5.3 nLx_disafr_total 9.1; RUN; PROC SORT DATA=example6A OUT=example6A; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example6A OUT=example6A (DROP=time) METHOD=NONE; CONVERT nLx_disafr_total=Tx_disafr_total/TRANSFORM=(SUM); RUN; PROC SORT DATA=example6A OUT=example6A; BY agegr; RUN; DATA example6A; RETAIN x agegr lx nLx ex pix Ix pix_total nLx_disafr_total Tx_disafr_total DFLEx_total DFLEx; SET example6A; DFLEx_total=Tx_disafr_total/lx; FORMAT DFLEx_total 4.1; RUN; DATA Sullivan.example6A; RETAIN x agegroup lx nLx ex pix Ix pix_total nLx_disafr_total Tx_disafr_total DFLEx_total DFLEx; SET example6A; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' lx='Numbers surviving to age x' nLx='Person years lived in age interval' ex='Total life Expectancy' pix='Proportion of age group in survey with disability' Ix='Proportion in institutions' pix_total='Proportion of age group (total) with disability' nLx_disafr_total='Person years lived without disability in age interval' Tx_disafr_total='Total years lived without disability from age x' DFLEx_total='Disability-free life expectancy (including inst)' DFLEx='Disability-free life expectancy (excluding inst)'; RUN; /Approximate standard errors ignoring the variance of the mortality rates/ DATA example6B; merge example6A input_example4; BY agegr; S2_pix_total=(1-Ix)*(1-Ix)*pix_total*(1-pix_total)/Nx; L2S2_pix_total=(nLx**2)*S2_pix_total; KEEP x agegr lx nLx ex pix Ix pix_total DFLEx_total Nx S2_pix_total L2S2_pix_total;

17

FORMAT S2_pix_total 8.6 L2S2_pix_total 10.0; RUN; PROC SORT DATA=example6B OUT=example6B; BY DESCENDING agegr; RUN; PROC EXPAND DATA=example6B OUT=example6B (DROP=time) METHOD=NONE; CONVERT L2S2_pix_total=T_L2S2_pix_total/TRANSFORM=(SUM); RUN; PROC SORT DATA=example6B OUT=example6B; BY agegr; RUN; DATA example6B; RETAIN x agegr lx nLx ex pix Ix pix_total DFLEx_total Nx S2_pix_total L2S2_pix_total T_L2S2_pix_total S2_DFLEx_total S_DFLEx_total; set example6B; S2_DFLEx_total=T_L2S2_pix_total/(lx**2); S_DFLEx_total=sqrt(S2_DFLEx_total); FORMAT S2_DFLEx_total 7.5 S_DFLEx_total 5.3; RUN; DATA Sullivan.example6B; RETAIN x agegroup lx nLx ex pix Ix pix_total DFLEx_total Nx S2_pix_total L2S2_pix_total T_L2S2_pix_total S2_DFLEx_total S_DFLEx_total; SET example6B; drop agegr; length agegroup $ 10; IF x=0 THEN agegroup='0'; IF x=1 THEN agegroup='1-4'; IF x=5 THEN agegroup='5-9'; IF x=5 THEN agegroup='5-9'; IF x=10 THEN agegroup='10-14'; IF x=15 THEN agegroup='15-19'; IF x=20 THEN agegroup='20-24'; IF x=25 THEN agegroup='25-29'; IF x=30 THEN agegroup='30-34'; IF x=35 THEN agegroup='35-39'; IF x=40 THEN agegroup='40-44'; IF x=45 THEN agegroup='45-49'; IF x=50 THEN agegroup='50-54'; IF x=55 THEN agegroup='55-59'; IF x=60 THEN agegroup='60-64'; IF x=65 THEN agegroup='65-69'; IF x=70 THEN agegroup='70-74'; IF x=75 THEN agegroup='75-79'; IF x=80 THEN agegroup='80-84'; IF x=85 THEN agegroup='85+'; LABEL x='Age at start of interval' agegroup='Age group' lx='Numbers surviving to age x' nLx='Person years lived in age interval' ex='Total life Expectancy' pix='Proportion of age group in survey with disability' Ix='Proportion in institutions' pix_total='Proportion of age group (total) with disability' DFLEx_total='Disability-free life expectancy (including inst)' Nx='Number in survey in age interval' S2_pix_total='Variance of prevalence disability-free' S2_DFLEx_total='Variance of DFLEx' S_DFLEx_total='Standard error of DFLEx'; RUN;

18

SPSS Program

/*******************************************************************************************************************/

SULLIVAN HEALTH EXPECTANCY USING AN UNABRIDGED LIFE TABLE : EXAMPLE 1 /*******************************************************************************************************************/

/******** Calculation of the life table and life expectancy ********/ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example1' /CELLRANGE=full /READNAMES=on . COMPUTE mx = Dx / Px . COMPUTE qx = mx/(1+(0.5*mx)) . IF (x = 0) qx = 1-(1-((Dx-Dx2)/Px1))*(1-(Dx2/B)) . IF (x = 85) qx = $SYSMIS . IF (x = 0) lx = 100000 . IF (x > 0) lx = lag(lx)*(1-lag(qx)) . SORT CASES BY x (D) . COMPUTE LLx = (lx+lag(lx))/2 . IF (x = 0) LLx = 0.2*lx+0.8*lag(lx) . IF (x = 85) LLx = lx/mx . DO IF x = 85 . COMPUTE Tx = LLx . ELSE . COMPUTE Tx = lag(Tx) + LLx . END IF. SORT CASES BY x (A) . COMPUTE ex = Tx/lx . FORMAT pix (F5.3) mx qx (F8.6) ex (F4.1) . SAVE OUTFILE='_____\example1.sav' /* Specify the directory of the output data */ /KEEP=x Px Dx mx qx lx LLx Tx ex pix /COMPRESSED .

/******** Calculation of Disability-Free Life Expectancy (DFLE) ********/ GET FILE='_____\example1.sav' . /* Specify the directory of the output data */ COMPUTE LLx_disafr = LLx*(1-pix) . SORT CASES BY x (D) . DO IF x = 85 . COMPUTE Tx_disafr = LLx_disafr . ELSE . COMPUTE Tx_disafr = lag(Tx_disafr) + LLx_disafr . END IF .

19

SORT CASES BY x (A) . COMPUTE DFLEx = Tx_disafr/lx . COMPUTE percDFLEx = 100*(DFLEx/ex) . FORMAT DFLEx percDFLEx (F4.1) . VARIABLE LABELS x 'Age' Px 'Mid-year population' Dx 'No. deaths' mx 'Central Death rate' qx 'Conditional probability of death' lx 'Numbers surviving to age x' LLx 'Person years lived at age x' Tx 'Total number of years lived from age x' ex 'Total Life Expectancy' pix 'Proportion with disability' LLx_disafr 'Person years lived without disability at age x' Tx_disafr 'Total years lived without disability from age x' DFLEx 'Disability-free life expectancy' percDFLEx 'Proportion of life spent disability-free' . SAVE OUTFILE='_____\example1.sav' /* Specify the directory of the output data */ /COMPRESSED . /*******************************************************************************************************************/

/*SULLIVAN HEALTH EXPECTANCY USING AN UNABRIDGED LIFE TABLE : EXAMPLE 2 */ /*******************************************************************************************************************/

/******** Calculation of the life table and life expectancy ********/ GET FILE='_____\example1.sav' . /* Specify the directory of the output data */ IF (x = 0) agegr = 0 . IF (x = 1 or x = 2 or x = 3 or x = 4) agegr = 1 . IF (x = 5 or x = 6 or x = 7 or x = 8 or x = 9) agegr = 5 . IF (x = 10 or x = 11 or x = 12 or x = 13 or x = 14) agegr = 10 . IF (x = 15 or x = 16 or x = 17 or x = 18 or x = 19) agegr = 15 . IF (x = 20 or x = 21 or x = 22 or x = 23 or x = 24) agegr = 20 . IF (x = 25 or x = 26 or x = 27 or x = 28 or x = 29) agegr = 25 . IF (x = 30 or x = 31 or x = 32 or x = 33 or x = 34) agegr = 30 . IF (x = 35 or x = 36 or x = 37 or x = 38 or x = 39) agegr = 35 . IF (x = 40 or x = 41 or x = 42 or x = 43 or x = 44) agegr = 40 . IF (x = 45 or x = 46 or x = 47 or x = 48 or x = 49) agegr = 45 . IF (x = 50 or x = 51 or x = 52 or x = 53 or x = 54) agegr = 50 . IF (x = 55 or x = 56 or x = 57 or x = 58 or x = 59) agegr = 55 . IF (x = 60 or x = 61 or x = 62 or x = 63 or x = 64) agegr = 60 . IF (x = 65 or x = 66 or x = 67 or x = 68 or x = 69) agegr = 65 . IF (x = 70 or x = 71 or x = 72 or x = 73 or x = 74) agegr = 70 . IF (x = 75 or x = 76 or x = 77 or x = 78 or x = 79) agegr = 75 . IF (x = 80 or x = 81 or x = 82 or x = 83 or x = 84) agegr = 80 . IF (x = 85) agegr = 85 . FORMAT agegr (F3.0) . VALUE LABELS agegr 0 "0" 1 "1-4" 5 "5-9" 10 "10-14" 15 "15-19" 20 "20-24" 25 "25-29" 30 "30-34" 35 "35-39" 40 "40-44" 45 "45-49" 50 "50-54" 55 "55-59" 60 "60-64"

20

65 "65-69'" 70 "70-74" 75 "75-79" 80 "80-84" 85 "85+" . AGGREGATE /OUTFILE '_____\example2.sav' /* Specify the directory of the output data */ /BREAK agegr /x_a = FIRST(x) / pix_a = FIRST(pix) / lx_a = FIRST(lx) / nLx = SUM(LLx) . GET FILE='_____\example2.sav' /* Specify the directory of the output data */ /RENAME x_a = x pix_a = pix lx_a = lx . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE Tx = nLx . ELSE . COMPUTE Tx = lag(Tx) + nLx . END IF. SORT CASES BY agegr (A) . COMPUTE ex = Tx/lx . FORMAT ex (F4.1) . SAVE OUTFILE='_____\example2.sav' /* Specify the directory of the output data */ /KEEP=x agegr lx nLx Tx ex pix /COMPRESSED .

/******** Calculation of Disability-Free Life Expectancy (DFLE) ********/ GET FILE='_____\example2.sav' . /* Specify the directory of the output data */ COMPUTE nLx_disafr = nLx*(1-pix) . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE Tx_disafr = nLx_disafr . ELSE . COMPUTE Tx_disafr = lag(Tx_disafr) + nLx_disafr . END IF . SORT CASES BY agegr (A) . COMPUTE DFLEx = Tx_disafr/lx . COMPUTE percDFLEx = 100*(DFLEx/ex) . FORMAT DFLEx percDFLEx (F4.1) . VARIABLE LABELS x 'Age at start of interval' agegr 'Age group' nLx 'Person years lived in age interval' Tx 'Total number of years lived from age x' ex 'Total Life Expectancy' pix 'Proportion with disability' nLx_disafr 'Person years lived without disability in age interval' Tx_disafr 'Total years lived without disability from age x' DFLEx 'Disability-free life expectancy' percDFLEx 'Proportion of life spent disability-free' . SAVE OUTFILE='_____\example2.sav' /* Specify the directory of the output data */

21

/COMPRESSED . /*******************************************************************************************************************/

/***SULLIVAN HEALTH EXPECTANCY USING AN ABRIDGED LIFE TABLE : EXAMPLE 3 ***/ /*******************************************************************************************************************/

/******** Calculation of the life table and life expectancy ********/ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example1' /CELLRANGE=full /READNAMES=on . IF (x = 0) agegr = 0 . IF (x = 1 or x = 2 or x = 3 or x = 4) agegr = 1 . IF (x = 5 or x = 6 or x = 7 or x = 8 or x = 9) agegr = 5 . IF (x = 10 or x = 11 or x = 12 or x = 13 or x = 14) agegr = 10 . IF (x = 15 or x = 16 or x = 17 or x = 18 or x = 19) agegr = 15 . IF (x = 20 or x = 21 or x = 22 or x = 23 or x = 24) agegr = 20 . IF (x = 25 or x = 26 or x = 27 or x = 28 or x = 29) agegr = 25 . IF (x = 30 or x = 31 or x = 32 or x = 33 or x = 34) agegr = 30 . IF (x = 35 or x = 36 or x = 37 or x = 38 or x = 39) agegr = 35 . IF (x = 40 or x = 41 or x = 42 or x = 43 or x = 44) agegr = 40 . IF (x = 45 or x = 46 or x = 47 or x = 48 or x = 49) agegr = 45 . IF (x = 50 or x = 51 or x = 52 or x = 53 or x = 54) agegr = 50 . IF (x = 55 or x = 56 or x = 57 or x = 58 or x = 59) agegr = 55 . IF (x = 60 or x = 61 or x = 62 or x = 63 or x = 64) agegr = 60 . IF (x = 65 or x = 66 or x = 67 or x = 68 or x = 69) agegr = 65 . IF (x = 70 or x = 71 or x = 72 or x = 73 or x = 74) agegr = 70 . IF (x = 75 or x = 76 or x = 77 or x = 78 or x = 79) agegr = 75 . IF (x = 80 or x = 81 or x = 82 or x = 83 or x = 84) agegr = 80 . IF (x = 85) agegr = 85 . FORMAT agegr (F3.0) . VALUE LABELS agegr 0 "0" 1 "1-4" 5 "5-9" 10 "10-14" 15 "15-19" 20 "20-24" 25 "25-29" 30 "30-34" 35 "35-39" 40 "40-44" 45 "45-49" 50 "50-54" 55 "55-59" 60 "60-64" 65 "65-69'" 70 "70-74" 75 "75-79" 80 "80-84" 85 "85+" . AGGREGATE /OUTFILE '_____\example3.sav' /* Specify the directory of the output data */ /BREAK agegr /x_a = FIRST(x) / pix_a = FIRST(pix) / Px1_a = FIRST(Px1) / Dx2_a = FIRST(Dx2) / B_a = FIRST(B) / Px_a=SUM(Px) / Dx_a = SUM(Dx) . GET FILE='_____\example3.sav' /* Specify the directory of the output data */ /RENAME x_a = x pix_a = pix Px1_a = Px1 Dx2_a = Dx2 B_a = B Px_a = Px Dx_a = Dx . COMPUTE nmx = Dx / Px . COMPUTE ax = 0.5 . COMPUTE nqx = (5*nmx)/(1+((1-ax)*5*nmx)) . IF (agegr = 0) nqx = 1-(1-((Dx-Dx2)/Px1))*(1-(Dx2/B)) .

22

IF (agegr = 1) nqx = (4*nmx)/(1+((1-ax)*4*nmx)) . IF (agegr = 85) nqx = $SYSMIS . IF (agegr = 0) lx = 100000 . IF (agegr > 0) lx = lag(lx)*(1-lag(nqx)) . SORT CASES BY agegr (D) . COMPUTE nLx = ((lx*5*ax)+(lag(lx)*5*(1-ax))) . IF (agegr = 0) nLx = 0.2*lx+0.8*lag(lx) . IF (agegr = 1) nLx = ((lx*4*ax)+(lag(lx)*4*(1-ax))) . IF (agegr = 85) nLx = lx/nmx . DO IF agegr = 85 . COMPUTE Tx = nLx . ELSE . COMPUTE Tx = lag(Tx) + nLx . END IF. SORT CASES BY agegr (A) . COMPUTE ex = Tx/lx . FORMAT pix (F5.3) Px (F8.1) Dx (F6.0) ax (F3.1) nmx (F8.6) nqx (F10.8) lx nLx Tx (F9.1) ex (F4.1) . SAVE OUTFILE='_____\example3.sav' /* Specify the directory of the output data */ /KEEP=x agegr Px Dx nmx ax nqx lx nLx Tx ex pix /COMPRESSED .

/******** Calculation of Disability-Free Life Expectancy (DFLE) ********/ GET FILE='_____\example3.sav' . /* Specify the directory of the output data */ COMPUTE nLx_disafr = nLx*(1-pix) . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE Tx_disafr = nLx_disafr . ELSE . COMPUTE Tx_disafr = lag(Tx_disafr) + nLx_disafr . END IF . SORT CASES BY agegr (A) . COMPUTE DFLEx = Tx_disafr/lx . COMPUTE percDFLEx = 100*(DFLEx/ex) . EXECUTE . FORMAT nLx_disafr Tx_disafr (F9.1) DFLEx percDFLEx (F4.1) . VARIABLE LABELS x 'Age at start of interval' agegr 'Age group' Px 'Mid-year population' Dx 'No. deaths' nmx 'Central Death rate' nqx 'Conditional probability of death in age interval' lx 'Numbers surviving to age x' nLx 'Person years lived in age interval' Tx 'Total number of years lived from age x' ex 'Total Life Expectancy' pix 'Proportion with disability' nLx_disafr 'Person years lived without disability in age interval'

23

Tx_disafr 'Total years lived without disability from age x' DFLEx 'Disability-free life expectancy' percDFLEx 'Proportion of life spent disability-free' . SAVE OUTFILE='_____\example3.sav' /* Specify the directory of the output data */ /COMPRESSED . /*******************************************************************************************************************/

/*THE STANDARD ERROR OF THE SULLIVAN HEALTH EXPECTANCY : EXAMPLE 4 */ /*******************************************************************************************************************/

/******** Approximate standard errors ignoring the variance of the mortality rates ********/ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example4' /CELLRANGE=full /READNAMES=on . MATCH FILES /FILE=* /FILE='_____\example3.sav' /* Specify the directory of the output data */ /BY agegr. COMPUTE S2_pix = (pix*(1-pix))/Nx . COMPUTE L2S2_pix = (nLx**2)*S2_pix . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE T_L2S2_pix = L2S2_pix . ELSE . COMPUTE T_L2S2_pix = lag(T_L2S2_pix) + L2S2_pix . END IF. SORT CASES BY agegr (A) . COMPUTE S2_DFLEx = T_L2S2_pix/(lx**2) . COMPUTE S_DFLEx = sqrt(S2_DFLEx) . EXECUTE . FORMAT S2_pix (F8.6) L2S2_pix T_L2S2_pix (F10.0) S2_DFLEx (F7.5) S_DFLEx (F5.3) . VARIABLE LABELS Nx 'Number in survey in age interval' S2_pix 'Variance of prevalence disability-free' S2_DFLEx 'Variance of DFLEx' S_DFLEx 'Standard error of DFLEx' . SAVE OUTFILE='_____\example4A.sav' /* Specify the directory of the output data */ /KEEP=x agegr ax Dx nqx lx nLx ex pix nLx_disafr Tx_disafr DFLEx Nx S2_pix L2S2_pix T_L2S2_pix S2_DFLEx S_DFLEx / COMPRESSED .

/******** Standard errors taking into account the variance of the mortality rates ********/

24

GET FILE='_____\example4A.sav' /* Specify the directory of the output data */ /RENAME S2_DFLEx = S2_DFLEx_1 . COMPUTE S2_qx = ((nqx**2)*(1-nqx))/Dx . IF (agegr = 85) S2_qx = 0 . SORT CASES BY agegr (D) . COMPUTE y = (((1-ax)*5*(1-pix))+lag(DFLEx)) . IF (agegr = 0) y = (((1-ax)*(1-pix))+lag(DFLEx)) . IF (agegr = 1) y = (((1-ax)*4*(1-pix))+lag(DFLEx)) . IF (agegr = 85) y = 0 . COMPUTE z = ((y**2)*(lx**2)*(S2_qx)) . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE T_z = z . ELSE . COMPUTE T_z = lag(T_z) + z . END IF. SORT CASES BY agegr (A) . COMPUTE S2_DFLEx_2 = T_z/(lx**2) . COMPUTE S2_DFLEx = S2_DFLEx_1+S2_DFLEx_2 . FORMAT S2_DFLEx_1 (F7.5) S2_qx (F10.8) y (F7.4) z T_z (F12.3) S2_DFLEx_2 S2_DFLEx (F7.5) . VARIABLE LABELS S2_qx 'Variance of probability of death' S2_DFLEx_1 'Variance of DFLEx (due to prevalence)' S2_DFLEx_2 'Variance of DFLEx (due to mortality)' S2_DFLEx 'Total variance of DFLEx' . SAVE OUTFILE='_____\example4B.sav' /* Specify the directory of the output data */ /DROP = Nx nLx ex nLx_disafr Tx_disafr S2_pix L2S2_pix T_L2S2_pix S_DFLEx /COMPRESSED .

/*******************************************************************************************************************/

/**TESTING THE EQUALITY OF TWO SULLIVAN HEALTH EXPECTANCIES : EXAMPLE 5 **/ /*******************************************************************************************************************/ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example5' /CELLRANGE=full /READNAMES=on . COMPUTE x = agegr . COMPUTE diff_DFLE = DFLEf-DFLEm . COMPUTE S_diff_DFLE = S_DFLEf+S_DFLEm . COMPUTE z = diff_DFLE/S_diff_DFLE . COMPUTE pvalue = 2*(1-CDFNORM(z)). STRING p (A6) . IF (pvalue >0.20) p=">0.20" . IF (pvalue <0.20) p="<0.20" . IF (pvalue <0.10) p="<0.10" . IF (pvalue <0.05) p="<0.05" . IF (pvalue <0.02) p="<0.02" . IF (pvalue <0.01) p="<0.01" .

25

IF (pvalue <0.002) p="<0.002" . IF (pvalue <0.001) p="<0.001" . FORMAT x (F3.0) DFLEf DFLEm (F4.1) S_DFLEf S_DFLEm diff_DFLE S_diff_DFLE z (F4.2) . VALUE LABELS agegr 0 "0" 1 "1-4" 5 "5-9" 10 "10-14" 15 "15-19" 20 "20-24" 25 "25-29" 30 "30-34" 35 "35-39" 40 "40-44" 45 "45-49" 50 "50-54" 55 "55-59" 60 "60-64" 65 "65-69'" 70 "70-74" 75 "75-79" 80 "80-84" 85 "85+" . VARIABLE LABELS x 'Age at start of interval' agegr 'Age group' DFLEf 'Disability-free life expectancy females' S_DFLEf 'Standard error of DFLE females' DFLEm 'Disability-free life expectancy males' S_DFLEm 'Standard error of DFLE males' diff_DFLE 'Difference in DFLE between males and females' S_diff_DFLE 'Approximate standard error of difference in DFLE between males and females' z 'z statistic' p 'p value' . SAVE OUTFILE='_____\example5.sav' /* Specify the directory of the output data */ /KEEP=x agegr DFLEf S_DFLEf DFLEm S_DFLEm diff_DFLE S_diff_DFLE z p /COMPRESSED . /*******************************************************************************************************************/

/** SULLIVAN HEALTH EXPECTANCY USING SEPARATE DATA SOURCES FOR INSTITUTIONALISED: EXAMPLE 6 **/

/*******************************************************************************************************************/

/******** Calculation of Disability-Free Life Expectancy (DFLE) ********/ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example6' /CELLRANGE=full /READNAMES=on . MATCH FILES /FILE=* /FILE='_____\example3.sav' /* Specify the directory of the output data */ /BY agegr . COMPUTE pix_total = ((1-Ix)*(pix))+Ix . COMPUTE nLx_disafr_total=nLx*(1-pix_total) . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE Tx_disafr_total = nLx_disafr_total . ELSE . COMPUTE Tx_disafr_total = lag(Tx_disafr_total) + nLx_disafr_total . END IF. SORT CASES BY agegr (A) . COMPUTE DFLEx_total = Tx_disafr_total/lx . EXECUTE . FORMAT Ix pix_total (F5.3) nLx_disafr_total Tx_disafr_total (F9.1) DFLEx_total (F4.1) .

26

VARIABLE LABELS Ix 'Proportion in institutions' pix_total 'Proportion of age group (total) with disability' nLx_disafr_total 'Person years lived without disability in age interval' Tx_disafr_total 'Total years lived without disability from age x' DFLEx 'Disability-free life expectancy (excluding inst)' DFLEx_total 'Disability-free life expectancy (including inst)' . SAVE OUTFILE='_____\example6A.sav' /* Specify the directory of the output data */ /KEEP=x agegr lx nLx ex pix Ix pix_total nLx_disafr_total Tx_disafr_total DFLEx_total DFLEx /COMPRESSED . /* Approximate standard errors ignoring the variance of the mortality rates */ GET DATA /TYPE=XLS /FILE='_____\input_examples.xls' /* Specify the directory of the input data */ /SHEET=name 'input_example4' /CELLRANGE=full /READNAMES=on . MATCH FILES /FILE=* /FILE='_____\example6A.sav' /* Specify the directory of the output data */ /BY agegr . COMPUTE S2_pix_total = (1-Ix)*(1-Ix)*pix_total*(1-pix_total)/Nx . COMPUTE L2S2_pix_total=(nLx**2)*S2_pix_total . SORT CASES BY agegr (D) . DO IF agegr = 85 . COMPUTE T_L2S2_pix_total = L2S2_pix_total . ELSE . COMPUTE T_L2S2_pix_total = lag(T_L2S2_pix_total) + L2S2_pix_total . END IF. SORT CASES BY agegr (A) . COMPUTE S2_DFLEx_total=T_L2S2_pix_total/(lx**2) . COMPUTE S_DFLEx_total=sqrt(S2_DFLEx_total) . FORMAT S2_pix_total (F8.6) L2S2_pix_total T_L2S2_pix_total (F10.0) S2_DFLEx_total (F7.5) S_DFLEx_total (F5.3) . VARIABLE LABELS Nx 'Number in survey in age interval' S2_pix_total 'Variance of prevalence disability-free' S2_DFLEx_total 'Variance of DFLEx' S_DFLEx_total 'Standard error of DFLEx' . SAVE OUTFILE='_____\example6B.sav' /* Specify the directory of the output data */ /KEEP=x agegr lx nLx ex pix Ix pix_total DFLEx_total Nx S2_pix_total L2S2_pix_total T_L2S2_pix_total S2_DFLEx_total S_DFLEx_total /COMPRESSED .