* agesex standardise.sps * Ludi Simpson May 2004 * Macro for 'indirect' age-sex standardisation. * The macro takes a file which includes at least the following four variables: * age-group, sex, a dichotomous social indicator, a population variable across whose categories * the social indicator is to be compared. * Age-sex standardisation computes the number expected with value 1 on the social * indicator, by applying age-sex rates for the whole population to the age-sex * population strucures of each population category; the age-sex standardised rate is the * observed count of the social indicator as a percentage of the expected rate: rates more * than 100 show high indication even after the age-sex structure has been taken into account. * The macro outputs the crude and age-sex standardised rates, and the all-population * age-sex rates. * Usually age-sex standardisation is required because the social indicator is related to age * and the categorical variable defines populations with varied age structure. * To use these commands: * (a) the user defines temporary files as in the first three lines of code, * (b) includes the macro definition as below from the define command to the !enddefine command * (c) calls the macro as in the example at the end of this file. The call begins with the macro name. * The user's variables for age, sex, category variable and indicator variable follow the = signs in * the macro call. * The example uses the 1991 individual * SAR to calculate age-sex standardised lack of household car ownership for each ethnic group * (which is lowest for those in the 40s and highest for those over 64). The lack of car ownership * is computed as a 0-1 dichotomy. * If age standardisation is required separately for each sex, select one sex before * calling the macro. If age standardisation is required for persons, specify a variable that is * constant in the macro: sex=constant. * Note that after the macro your original file is no longer the current file. Get it again before running * the macro again. * This is indirect standardisation. Direct age-sex standardisation is possible given individual data. * However, it is unstable when the categories of age*sex*indicator*category have very small counts. * Textbook descriptions of age-sex standardisation can be found in most medical * and demography textbooks. Two detailed standard references are (a) Breslow * and Day, 'Statistical methods in cancer research, vol. 2: The analysis of cohort studies', * Oxford: University Press, 1988; (b) Goldblatt P and Jones D, Chapter 3 'Methods' * in Goldblatt P. (editor) 'Longitudinal study – mortality and social organisation'. * London: HMSO, 1990. file handle crossdata /name='c:\temp\crossdata.sav'. file handle categs /name='c:\temp\categs.sav'. file handle agesex /name='c:\temp\agesex.sav'. define !asstand (agegrp=!tokens(1) /sex=!tokens(1) /ind=!tokens(1) /categ=!tokens(1) ). set printback=off. * Only the results are printed. Next, aggregate the most detailed table required. aggregate outfile=* /break =!agegrp !sex !categ !ind /count=n. save outfile=crossdata. * Compute crude rates for each category. weight by count. aggregate outfile=categs /break=!categ /cpop=n /cruder=fin(!ind,1,1). * Compute age-sex rates for the whole population. aggregate outfile=agesex /break=!agegrp !sex /asrate=fin(!ind,1,1). * Compute the age-sex structure of each category. aggregate outfile=* /break=!agegrp !sex !categ /ascpop=n. * Apply the age-sex population rates to each category, to give expected counts. match files file=* /table=agesex /by !agegrp !sex. compute exppop=asrate*ascpop. * Sum the expected count for each category, match to the observed counts. aggregate outfile=* /break=!categ /exppop=sum(exppop). match files file=* /file=categs. * Compute and output the results. compute incid=cpop*cruder. compute crudepct=100*cruder. compute stndrate=100*incid/exppop. formats cpop incid exppop (f8.0) crudepct stndrate (f6.1). means cpop incid exppop crudepct stndrate by !categ /cells=sum. get file=agesex. formats !agegrp (f2.0). means asrate by !sex by !agegrp /cells=mean. set printback=on. !enddefine. * no car, age-sex standardised to compare ethnic groups. * NB select only the cases with non-missing data on all variables. select if not(missing(cars)). compute nocar=(cars eq 0). !asstand agegrp=age sex=sex categ=ethgroup ind=nocar.