******************************************************************** * File HALCyon PC covariate syntax_BoydOrr.do * BY Rachel Cooper, MRC Unit for Lifelong Health and Ageing at UCL * FOR HALCyon cross-cohort collaboration (funded by the New Dynamics of Ageing (RES-353-25-0001)) * DATASET Boyd Orr Cohort study * Date Created 19/08/2009 * last modified 19/09/2011 * PURPOSE Recodes and derives physical capability variables, basic sociodemographic variables * and indicators of socioeconomic position for use in cross-cohort analyses ************************************************************************************* # delimit; set more off; /*Creating break between newly recoded variables and variables in existing dataset with a blank variable */ gen recodes_below=. ; /*********************************************************************************/ /*Standard names and categories for demographic variables */ /* SEX */ gen sex=b3recsex ; label variable sex "Sex of study member" ; label define sexlab 1 "Male" 2 "Female" ; label values sex sexlab ; /*AGE */ /*Age at time of wave 3 assessment (when physical performance assessed) */ gen age_w3=b3age_exam ; label variable age_w3 "Age(y) at wave 3" ; /*Categories of age at wave 3 assessment */ /*in 10 year age groups 60-69, 70-79, 80-89 years */ gen agecat_w3=age_w3 ; recode agecat_w3 (min/69.999=1) (70/79.999=2) (80/89.999=3) ; label variable agecat_w3 "Age at wave 3 (10y cat.)" ; label define agelab 1 "60-69" 2 "70-79" 3 "80+" ; label values agecat_w3 agelab ; /*in 5 year age groups 55-59, 60-64, 65-69, 70-74, 75-79, 80-84 years */ gen agecat5_w3=age_w3 ; recode agecat5_w3 (min/59.999=0)(60/64.999=1) (65/69.999=2) (70/74.999=3) (75/79.999=4) (80/84.999=5) ; label variable agecat5_w3 "Age at wave 3 (5y cat.)" ; label define age5lab 0 "55-59" 1 "60-64" 2 "65-69" 3 "70-74" 4 "75-79" 5 "80+" ; label values agecat5_w3 age5lab ; /*********************************************************************************/ /* PHYSICAL CAPABILITY MEASURES */ /* STANDING BALANCE */ /* 2 trials performed at wave 3 - time up to a max of 30s that a person could balance on 1 leg with eyes open */ /*Trial 1 */ gen balancet1_w3=b3test1flamingo ; label variable balancet1_w3 "Balance time(s), trial 1" ; /*Trial 2 */ gen balancet2_w3=b3test2flamingo ; /*Assume person coded as 30.56 should have received a time of 30s and so recode */ recode balancet2_w3 30.56=30 ; label variable balancet2_w3 "Balance time(s), trial 2" ; /* Best balance time achieved over 2 trials */ /*2nd trial only undertaken if did not achieve 30s (max time) on first trial (although 14 people did take second trial despite this) */ gen bestbalance_w3=max(balancet1_w3, balancet2_w3) ; label variable bestbalance_w3 "Balance time(s), best of 2" ; /*Binary categorisations of 'best time' variable */ /*Able to balance for 30s or not */ gen bestbalance_30_w3=bestbalance_w3 ; recode bestbalance_30_w3 (min/29.99=0) (30=1) ; label variable bestbalance_30_w3 "Able to balance for 30s?, best" ; label define yeslab 0 "No" 1 "Yes" ; label values bestbalance_30_w3 yeslab ; /*Able to complete at least 5 seconds */ gen bestbalance_5_w3=bestbalance_w3 ; recode bestbalance_5_w3 (min/4.99=0) (5/30=1) ; label variable bestbalance_5_w3 "Able to balance for at least 5s?, best" ; label values bestbalance_5_w3 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen bestbalance_5_w3_opp=. ; replace bestbalance_5_w3_opp=1 if bestbalance_5_w3==0 ; replace bestbalance_5_w3_opp=0 if bestbalance_5_w3==1 ; label variable bestbalance_5_w3_opp "Able to balance for at least 5s?, best" ; label define nolab 1 "No" 0 "Yes" ; label values bestbalance_5_w3_opp nolab ; gen bestbalance_30_w3_opp=. ; replace bestbalance_30_w3_opp=1 if bestbalance_30_w3==0 ; replace bestbalance_30_w3_opp=0 if bestbalance_30_w3==1 ; label variable bestbalance_30_w3_opp "Able to balance for 30s?, best" ; label values bestbalance_30_w3_opp nolab ; /*Binary categorisations of trial 1 variable */ /*As the second trial of balance was only undertaken if a participant did not achieve 30s on first trial it may be more appropriate */ /*for comparison with other studies which only asked participants to perform 1 trial of balance to use results from the first trial only */ /*Able to balance for 30s or not */ gen balancet1_30_w3=balancet1_w3 ; recode balancet1_30_w3 (min/29.99=0) (30=1) ; label variable balancet1_30_w3 "Able to balance for 30s?, trial 1" ; label values balancet1_30_w3 yeslab ; /*Able to complete at least 5 seconds */ gen balancet1_5_w3=balancet1_w3 ; recode balancet1_5_w3 (min/4.99=0) (5/30=1) ; label variable balancet1_5_w3 "Able to balance for at least 5s?, trial 1" ; label values balancet1_5_w3 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen balancet1_30_w3_opp=. ; replace balancet1_30_w3_opp=1 if balancet1_30_w3==0 ; replace balancet1_30_w3_opp=0 if balancet1_30_w3==1 ; label variable balancet1_30_w3_opp "Able to balance for 30s?, trial 1" ; label values balancet1_30_w3_opp nolab ; gen balancet1_5_w3_opp=. ; replace balancet1_5_w3_opp=1 if balancet1_5_w3==0 ; replace balancet1_5_w3_opp=0 if balancet1_5_w3==1 ; label variable balancet1_5_w3_opp "Able to balance for at least 5s?, trial 1" ; label values balancet1_5_w3_opp nolab ; /*Binary categorisations of trial 2 variable */ /*Able to balance for 30s or not */ gen balancet2_30_w3=balancet2_w3 ; recode balancet2_30_w3 (min/29.99=0) (30=1) ; label variable balancet2_30_w3 "Able to balance for 30s?, trial 2" ; label values balancet2_30_w3 yeslab ; /*Able to complete at least 5 seconds */ gen balancet2_5_w3=balancet2_w3 ; recode balancet2_5_w3 (min/4.99=0) (5/30=1) ; label variable balancet2_5_w3 "Able to balance for at least 5s?, trial 2" ; label values balancet2_5_w3 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen balancet2_30_w3_opp=. ; replace balancet2_30_w3_opp=1 if balancet2_30_w3==0 ; replace balancet2_30_w3_opp=0 if balancet2_30_w3==1 ; label variable balancet2_30_w3_opp "Able to balance for 30s?, trial 2" ; label values balancet2_30_w3_opp nolab ; gen balancet2_5_w3_opp=. ; replace balancet2_5_w3_opp=1 if balancet2_5_w3==0 ; replace balancet2_5_w3_opp=0 if balancet2_5_w3==1 ; label variable balancet2_5_w3_opp "Able to balance for at least 5s?, trial 2" ; label values balancet2_5_w3_opp nolab ; gen avbalance=. ; replace avbalance=(balancet1_w3+balancet2_w3)/2 if balancet2_w3!=. & balancet1_w3!=. ; replace avbalance=balancet1_w3 if balancet1_w3!=. & balancet2_w3==. ; /*Able to complete at least 5 seconds */ gen avbalance_5_w3=avbalance ; recode avbalance_5_w3 (min/4.99=0) (5/30=1) ; label variable avbalance_5_w3 "Able to balance for at least 5s?, average" ; label values avbalance_5_w3 yeslab ; gen avbalance_5_w3_opp=. ; replace avbalance_5_w3_opp=1 if avbalance_5_w3==0 ; replace avbalance_5_w3_opp=0 if avbalance_5_w3==1 ; label variable avbalance_5_w3_opp "Able to balance for at least 5s?, average" ; label values avbalance_5_w3_opp nolab ; /*Creating a categorisation of balance which instead of using a specific time as a cut-point, identifies those in the bottom */ /*20% of performance by sex */ /*Using best performance */ egen bbal20m=cut(bestbalance_w3) if sex==1, group(5) ; egen bbal20f=cut(bestbalance_w3) if sex==2, group(5) ; table bbal20m, c(min bestbalance_w3 max bestbalance_w3) ; table bbal20f, c(min bestbalance_w3 max bestbalance_w3) ; gen bestbalance_b20_w3=. ; replace bestbalance_b20_w3=bbal20m if sex==1 & bbal20m!=. ; replace bestbalance_b20_w3=bbal20f if sex==2 & bbal20f!=. ; recode bestbalance_b20_w3 1/4=0 0=1 ; label variable bestbalance_b20_w3 "In bottom 20% of balance times, best of 2 trials" ; label define b20lab 0 "Top 80%" 1 "Bottom 20%" ; label values bestbalance_b20_w3 b20lab ; label variable bbal20m "Quintiles of balance time, best of 2 trials, men" ; label variable bbal20f "Quintiles of balance time, best of 2 trials, women" ; /*Using performance in trial 1 */ egen bal20m=cut(balancet1_w3) if sex==1, group(5) ; egen bal20f=cut(balancet1_w3) if sex==2, group(5) ; table bal20m, c(min balancet1_w3 max balancet1_w3) ; table bal20f, c(min balancet1_w3 max balancet1_w3) ; gen balancet1_b20_w3=. ; replace balancet1_b20_w3=bal20m if sex==1 & bal20m!=. ; replace balancet1_b20_w3=bal20f if sex==2 & bal20f!=. ; recode balancet1_b20_w3 1/4=0 0=1 ; label variable balancet1_b20_w3 "In bottom 20% of balance times, trial 1?" ; label values balancet1_b20_w3 b20lab ; label variable bal20m "Quintiles of balance time, trial 1, men" ; label variable bal20f "Quintiles of balance time, trial 1, women" ; /*TIMED GET UP AND GO */ /* 2 trials performed at wave 3 - time taken in seconds to get up from a chair, walk a distance of 3m at usual pace, turn on touching line */ /* return to chair and sit back down again */ /*Trial 1 */ gen tugtimet1_w3=b3walk1time ; label variable tugtimet1_w3 "TUG time (s), trial 1" ; /*Trial 2 */ gen tugtimet2_w3=b3walk2time ; label variable tugtimet2_w3 "TUG time (s), trial 2" ; /*Fastest TUG time over 2 trials */ gen besttugtime_w3=min(tugtimet1_w3, tugtimet2_w3) ; label variable besttugtime_w3 "TUG time (s), best of 2" ; /*Average TUG time */ /*All participants have valid values for both trials */ gen avtugtime_w3=(tugtimet1_w3+tugtimet2_w3)/2 ; label variable avtugtime_w3 "Average TUG time (s)" ; /*Natural log transformations */ gen lnbesttugtime_w3=ln(besttugtime_w3) ; label variable lnbesttugtime_w3 "ln(best TUG time)" ; gen lnavtugtime_w3=ln(avtugtime_w3) ; label variable lnavtugtime_w3 "ln(average TUG time)" ; /*TUG speeds */ gen tugspeedt1_w3=6/tugtimet1_w3 ; gen tugspeedt2_w3=6/tugtimet2_w3 ; gen besttugspeed_w3=max(tugspeedt1_w3, tugspeedt2_w3) ; gen avtugspeed_w3=(tugspeedt1_w3+tugspeedt2_w3)/2 ; label variable tugspeedt1_w3 "TUG speed (m/s), trial 1" ; label variable tugspeedt2_w3 "TUG speed (m/s), trial 2" ; label variable besttugspeed_w3 "Best TUG speed (m/s)" ; label variable avtugspeed_w3 "Average TUG speed (m/s)" ; /***************************************************************************************/ /*SOCIOECONOMIC POSITION */ /*Childhood SEP */ /*Occupational class of male head of household at time of original survey in childhood */ gen occ_fath=b1socialclass1931 ; /*coding to missing those unclassified (incl missing) */ recode occ_fath 6=. ; label variable occ_fath "Father's occupation" ; label define seplab 1 "I or II" 2 "III" 3 "IV" 4 "V" 5 "Unemployed" ; label values occ_fath seplab ; /*Other childhood variables - b1incomecat, b1expendcat */ /*Adult SEP */ /*Occupational class in adulthood (1997) based on main employment of subject (for men and unmarried women) or spouse (for married women) */ gen occ_adult_hh=b2socclass_cat ; /*coding to missing those labelled as missing */ recode occ_adult 9=. ; label variable occ_adult_hh "Adult occupational class (head of house)" ; label define sep1lab 1 "I or II" 2 "III" 3 "IV orV or armed forces or unclassifiable" ; label values occ_adult_hh sep1lab ; /*Education variables */ /*have you had any full or part time further or higher education since leaving school? - asked in 1997 */ gen highered=highereducationq97 ; recode highered 9=. 2=0 ; label variable highered "Any further or higher education since school?" ; label define edlab 0 "No" 1 "Yes" ; label values highered edlab ; /*Age at leaving school - ascertained in 1997 */ gen agelefted=ageatschoolleavingq97 ; /*recoding missing */ recode agelefted 99=. ; label variable agelefted "Age at leaving school (y)" ;