******************************************************************** * File HALCyon PC covariate syntax_Caerphilly.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 Caerphilly Prospective Study (CaPS) * Date Created 19/08/2009 * last modified 14/12/2012 * PURPOSE Recodes and derives physical capability variables, basic sociodemographic variables * and covariates (indicators of socioeconomic position, health status, living alone and BMI) for use in cross-cohort analyses ************************************************************************************* # delimit; set more off; /*********************************************************************************/ /*Standard names and categories for demographic variables */ /* SEX */ /*All men so not applicable */ /*AGE */ gen age_w1=c1age ; gen age_w2=c2age ; gen age_w3=c3age ; gen age_w4=c4age ; /*calculating age at wave 5 using date of birth (c0dob) and date of exam (because of mis-reporting of age in c5age which is a self-report) */ /*use c0dob instead of either c1c1dob or c2c2dob because of inconsistencies between these 2 variables which have been checked and corrected in c0dob by YBS */ gen age_w5=(c5dateexam-c0dob)/365.25 ; /*Age at time of completion of wellbeing questionnaire - wave 6 */ gen age_w6=(c6q_returned_date-c0dob)/365.25 ; label variable age_w1 "Age at wave 1" ; label variable age_w2 "Age at wave 2" ; label variable age_w3 "Age at wave 3" ; label variable age_w4 "Age at wave 4" ; label variable age_w5 "Age at wave 5" ; label variable age_w6 "Age at wave 6" ; /*Categories of age at time of wave 5 assessment (when physical performance assessed) (range 60-83) */ /*in 10 year age groups 60-69, 70-79, 80-83 years */ gen agecat_w5=age_w5 ; recode agecat_w5 (min/69.999=1) (70/79.999=2) (80/89.999=3) ; label variable agecat_w5 "Age at wave 5 (10y cat.)" ; label define agelab 1 "60-69" 2 "70-79" 3 "80+" ; label values agecat_w5 agelab ; /*in 5 year age groups 60-64, 65-69, 70-74, 75-79, 80-84 years */ gen agecat5_w5=age_w5 ; recode agecat5_w5 (min/64.999=1) (65/69.999=2) (70/74.999=3) (75/79.999=4) (80/89.999=5) ; label variable agecat5_w5 "Age at wave 5 (5y cat.)" ; label define age5lab 1 "60-64" 2 "65-69" 3 "70-74" 4 "75-79" 5 "80+" ; label values agecat5_w5 age5lab ; /*********************************************************************************/ /* PHYSICAL CAPABILITY MEASURES */ /* STANDING BALANCE */ /* 2 trials performed at wave 5 - time up to a max of 30s that a person could balance on 1 leg with eyes open */ /*Trial 1 */ gen balancet1_w5=c5test1flamingo ; /*recode to missing those outside the expected range (3 men with values of 35.42, 56 and 1086) */ replace balancet1_w5=. if c5test1flamingo>30 ; label variable balancet1_w5 "Balance time(s), trial 1" ; /*Trial 2 */ gen balancet2_w5=c5test2flamingo ; /*recode to missing those who achieved 30s on first trial and are coded as 0 for this second trial */ replace balancet2_w5=. if c5test2flamingo==0 & c5test1flamingo==30 ; label variable balancet2_w5 "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 */ gen bestbalance_w5=max(balancet1_w5, balancet2_w5) ; label variable bestbalance_w5 "Balance time(s), best of 2" ; /*Binary categorisations of 'best time' variable */ /*Able to balance for 30s or not */ gen bestbalance_30_w5=bestbalance_w5 ; recode bestbalance_30_w5 (min/29.99=0) (30=1) ; label variable bestbalance_30_w5 "Able to balance for 30s?, best" ; label define yeslab 0 "No" 1 "Yes" ; label values bestbalance_30_w5 yeslab ; /*Able to complete at least 5 seconds */ gen bestbalance_5_w5=bestbalance_w5 ; recode bestbalance_5_w5 (min/4.99=0) (5/30=1) ; label variable bestbalance_5_w5 "Able to balance for at least 5s?, best" ; label values bestbalance_5_w5 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen bestbalance_5_w5_opp=. ; replace bestbalance_5_w5_opp=1 if bestbalance_5_w5==0 ; replace bestbalance_5_w5_opp=0 if bestbalance_5_w5==1 ; label variable bestbalance_5_w5_opp "Able to balance for at least 5s?, best" ; label define nolab 1 "No" 0 "Yes" ; label values bestbalance_5_w5_opp nolab ; gen bestbalance_30_w5_opp=. ; replace bestbalance_30_w5_opp=1 if bestbalance_30_w5==0 ; replace bestbalance_30_w5_opp=0 if bestbalance_30_w5==1 ; label variable bestbalance_30_w5_opp "Able to balance for 30s?, best" ; label values bestbalance_30_w5_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_w5=balancet1_w5 ; recode balancet1_30_w5 (min/29.99=0) (30=1) ; label variable balancet1_30_w5 "Able to balance for 30s?, trial 1" ; label values balancet1_30_w5 yeslab ; /*Able to complete at least 5 seconds */ gen balancet1_5_w5=balancet1_w5 ; recode balancet1_5_w5 (min/4.99=0) (5/30=1) ; label variable balancet1_5_w5 "Able to balance for at least 5s?, trial 1" ; label values balancet1_5_w5 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen balancet1_30_w5_opp=. ; replace balancet1_30_w5_opp=1 if balancet1_30_w5==0 ; replace balancet1_30_w5_opp=0 if balancet1_30_w5==1 ; label variable balancet1_30_w5_opp "Able to balance for 30s?, trial 1" ; label values balancet1_30_w5_opp nolab ; gen balancet1_5_w5_opp=. ; replace balancet1_5_w5_opp=1 if balancet1_5_w5==0 ; replace balancet1_5_w5_opp=0 if balancet1_5_w5==1 ; label variable balancet1_5_w5_opp "Able to balance for at least 5s?, trial 1" ; label values balancet1_5_w5_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 */ /*Using best performance */ egen bbal20=cut(bestbalance_w5), group(5) ; table bbal20, c(min bestbalance_w5 max bestbalance_w5) ; gen bestbalance_b20_w5=. ; replace bestbalance_b20_w5=bbal20 if bbal20!=. ; recode bestbalance_b20_w5 1/4=0 0=1 ; label variable bestbalance_b20_w5 "In bottom 20% of balance times, best of 2 trials" ; label define b20lab 0 "Top 80%" 1 "Bottom 20%" ; label values bestbalance_b20_w5 b20lab ; label variable bbal20 "Quintiles of balance time, best of 2 trials, men" ; /*Using performance in trial 1 */ egen bal20=cut(balancet1_w5), group(5) ; table bal20, c(min balancet1_w5 max balancet1_w5) ; gen balancet1_b20_w5=. ; replace balancet1_b20_w5=bal20 if bal20!=. ; recode balancet1_b20_w5 1/4=0 0=1 ; label variable balancet1_b20_w5 "In bottom 20% of balance times, trial 1?" ; label values balancet1_b20_w5 b20lab ; label variable bal20 "Quintiles of balance time, trial 1" ; /*Binary categorisations of trial 2 variable */ /*Able to balance for 30s or not */ gen balancet2_30_w5=balancet2_w5 ; recode balancet2_30_w5 (min/29.99=0) (30=1) ; label variable balancet2_30_w5 "Able to balance for 30s?, trial 2" ; label values balancet2_30_w5 yeslab ; /*Able to complete at least 5 seconds */ gen balancet2_5_w5=balancet2_w5 ; recode balancet2_5_w5 (min/4.99=0) (5/30=1) ; label variable balancet2_5_w5 "Able to balance for at least 5s?, trial 2" ; label values balancet2_5_w5 yeslab ; /*Coding balance the alternative way so that inability to balance is the 'positive' outcome */ gen balancet2_30_w5_opp=. ; replace balancet2_30_w5_opp=1 if balancet2_30_w5==0 ; replace balancet2_30_w5_opp=0 if balancet2_30_w5==1 ; label variable balancet2_30_w5_opp "Able to balance for 30s?, trial 2" ; label values balancet2_30_w5_opp nolab ; gen balancet2_5_w5_opp=. ; replace balancet2_5_w5_opp=1 if balancet2_5_w5==0 ; replace balancet2_5_w5_opp=0 if balancet2_5_w5==1 ; label variable balancet2_5_w5_opp "Able to balance for at least 5s?, trial 2" ; label values balancet2_5_w5_opp nolab ; gen avbalance=. ; replace avbalance=(balancet1_w5+balancet2_w5)/2 if balancet2_w5!=. & balancet1_w5!=. ; replace avbalance=balancet1_w5 if balancet1_w5!=. & balancet2_w5==. ; replace avbalance=balancet2_w5 if balancet1_w5==. & balancet2_w5!=. ; /*Able to complete at least 5 seconds */ gen avbalance_5_w5=avbalance ; recode avbalance_5_w5 (min/4.999=0) (5/30=1) ; label variable avbalance_5_w5 "Able to balance for at least 5s?, average" ; label values avbalance_5_w5 yeslab ; gen avbalance_5_w5_opp=. ; replace avbalance_5_w5_opp=1 if avbalance_5_w5==0 ; replace avbalance_5_w5_opp=0 if avbalance_5_w5==1 ; label variable avbalance_5_w5_opp "Able to balance for at least 5s?, average" ; label values avbalance_5_w5_opp nolab ; /*TIMED GET UP AND GO */ /* 2 trials performed at wave 5 - 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 */ /*First cleaning data */ /* Recode strange walking times, where it appears decimal place is wrong (provided by Kate Birnie) */ replace c5walk1time=16.67 if c0surveyno==4114 ; replace c5walk2time=14.75 if c0surveyno==4114 ; replace c5walk1time=10.75 if c0surveyno==5292 ; replace c5walk1time=12.09 if c0surveyno==7183 ; replace c5walk1time=9.39 if c0surveyno==7318 ; replace c5walk2time=12.98 if c0surveyno==2424 ; replace c5walk1time=10.32 if c0surveyno==2505 ; replace c5walk1time=10.43 if c0surveyno==2511 ; replace c5walk1time=7.26 if c0surveyno==2901 ; replace c5walk1time=10.13 if c0surveyno==6480 ; replace c5walk2time=13.81 if c0surveyno==1793 ; replace c5walk2time=10.37 if c0surveyno==2997 ; replace c5walk1time=. if c0surveyno==4812 ; /* Don't believe the values were < 6 sec given the values on second attempt therefore recode as missing (suggested by KB) */ replace c5walk1time=. if c5walk1time<6 ; replace c5walk2time=. if c5walk2time<6 ; /*Trial 1 */ gen tugtimet1_w5=c5walk1time ; label variable tugtimet1_w5 "TUG time (s), trial 1" ; /*Trial 2 */ gen tugtimet2_w5=c5walk2time ; label variable tugtimet2_w5 "TUG time (s), trial 2" ; /*Fastest TUG time over 2 trials */ gen besttugtime_w5=min(tugtimet1_w5, tugtimet2_w5) ; label variable besttugtime_w5 "TUG time (s), best of 2" ; /*Average TUG time */ /*21 participants only have 1 value so this is taken */ gen avtugtime_w5=(tugtimet1_w5+tugtimet2_w5)/2 ; replace avtugtime_w5=tugtimet1_w5 if tugtimet1_w5!=. & tugtimet2_w5==. ; replace avtugtime_w5=tugtimet2_w5 if tugtimet1_w5==. & tugtimet2_w5!=. ; label variable avtugtime_w5 "Average TUG time (s)" ; /*Natural log transformations */ gen lnbesttugtime_w5=ln(besttugtime_w5) ; label variable lnbesttugtime_w5 "ln(best TUG time)" ; gen lnavtugtime_w5=ln(avtugtime_w5) ; label variable lnavtugtime_w5 "ln(average TUG time)" ; /*TUG speeds */ gen tugspeedt1_w5=6/tugtimet1_w5 ; gen tugspeedt2_w5=6/tugtimet2_w5 ; gen besttugspeed_w5=max(tugspeedt1_w5, tugspeedt2_w5) ; gen avtugspeed_w5=(tugspeedt1_w5+tugspeedt2_w5)/2 ; replace avtugspeed_w5=tugspeedt1_w5 if tugspeedt1_w5!=. & tugspeedt2_w5==. ; replace avtugspeed_w5=tugspeedt2_w5 if tugspeedt1_w5==. & tugspeedt2_w5!=. ; label variable tugspeedt1_w5 "TUG speed (m/s), trial 1" ; label variable tugspeedt2_w5 "TUG speed (m/s), trial 2" ; label variable besttugspeed_w5 "Best TUG speed (m/s)" ; label variable avtugspeed_w5 "Average TUG speed (m/s)" ; /*Unable to complete test */ gen unable=. ; replace unable=1 if c5walkreasonnc==1 & avtugspeed_w5==. ; replace unable=1 if c5walkreasonnc==3 ; replace unable=1 if c5walkreasonnc==6 ; recode unable .=0 if avtugspeed_w5!=. ; /*Used a walking aid to complete TUG */ gen walkaid=. ; replace walkaid=1 if c5walkaidused==1 ; replace walkaid=0 if c5walkaidused==2 ; /***************************************************************************************/ /*SOCIOECONOMIC POSITION */ /*Childhood SEP */ /*Father's occupational class - ascertained at wave 1 (so missing for those who only joined in wave 2)*/ gen occ_fath=c1fathsocialclass ; /*recoding to standard order */ recode occ_fath 1=1 2=2 4=5 5=6 6=3 7=4 8=7 ; /*adding in those who are missing whose father's were unemployed for more than a year */ replace occ_fath=7 if c1fathsocialclass==. & c1fathunemployed==1 ; label variable occ_fath "Father's occupation" ; label define seplab 1 "I" 2" II" 3 "IIINM" 4 "IIIM" 5 "IV" 6 "V" 7 "Unemployed" ; label values occ_fath seplab ; /*Adult SEP */ /*Occupational class in adulthood at w1 */ gen occ_adult_w1=c1socialclass ; /*recoding to standard order */ recode occ_adult_w1 1=1 2=2 4=5 5=6 6=3 7=4 ; label variable occ_adult_w1 "Adult occupational class (wave 1)" ; label values occ_adult_w1 seplab ; /*Occupational class in adulthood at w2 */ gen occ_adult_w2=c2socialclass ; /*recoding to standard order */ recode occ_adult_w2 1=1 2=2 4=5 5=6 6=3 7=4 ; label variable occ_adult_w2 "Adult occupational class (wave 2)" ; label values occ_adult_w2 seplab ; /* Combining the info from the 2 waves */ gen occ_adult=. ; replace occ_adult=occ_adult_w2 if occ_adult_w2!=. ; replace occ_adult=occ_adult_w1 if occ_adult_w2==. & occ_adult_w1!=. ; label variable occ_adult "Adult occupational class (combined w2 and w1)" ; label values occ_adult seplab ; /*Binary categorisation in line with other studies */ gen occ_adult_2cat=occ_adult ; recode occ_adult_2cat 1/2=1 3/6=2 ; label variable occ_adult_2cat "Adult occupational class (binary)" ; label define occcatlab 1 "I or II" 2 "III, IV or V" ; label values occ_adult_2cat occcatlab ; /*Education variables */ /*Age at leaving school - ascertained at wave */ gen agelefted=c3ageleftschool ; label variable agelefted "Age at leaving school (y)" ; /*Binary categorisation as per other cohorts */ gen agelefted_2cat=agelefted ; recode agelefted_2cat min/15=1 16/max=2 ; label define ageedlab 1 "<=15" 2 ">15" ; label values agelefted_2cat ageedlab ; /*************************************************************/ /* OTHER COVARIATES */ /*HEIGHT, WEIGHT AND BMI*/ /* No changes to c5weight needed */ /*Divide c5standingheight by 1000 to give values in metres */ gen c5height=c5standingheight/1000 ; label variable c5height "Height at phase 5 (m)" ; gen c5heightcm=c5height*100 ; gen c5bmi=c5weight/(c5height*c5height) ; /*HEALTH STATUS */ /*History of disease at phase 5 (based on similar diseases to those used in other cohorts)*/ /*Including history of heart attack, heart failure, angina, diabetes, TIA stroke, cancer */ gen hp_w5=. ; replace hp_w5=1 if c5q6aheartattack==1 | c5q6bheartfailure==1 | c5q6cangina==1 | c5q6gdiabetes==1 | c5q6htia==1 | c5q7astroke==1 | c5q17acancer==1 ; replace hp_w5=0 if c5q6aheartattack==0 & c5q6bheartfailure==0 & c5q6cangina==0 & c5q6gdiabetes==0 & c5q6htia==0 & c5q7astroke==0 & c5q17acancer==2 ; label variable hp_w5 "History of specified health problems at phase 5" ; label define hplab 0 "No" 1 "Yes" ; label values hp_w5 hplab ; /*LIVING ALONE */ /*Creating a variable to identify people living alone at phase 5 based on their marital status */ gen livealn=. ; replace livealn=1 if c5q76maritalstatus==1 | c5q76maritalstatus==4 | c5q76maritalstatus==5 | c5q76maritalstatus==6 ; replace livealn=2 if c5q76maritalstatus==2 | c5q76maritalstatus==3 | c5q76maritalstatus==7 ; label define alonelab 1 "Living alone" 2 "Not living alone" ; label values livealn alonelab ;