Skip to content

Syntax

Body Mass Index

Creates bmi_dv

// Creates w_bmi_dv -  Body Mass Index
// INPUT FILE - w_indresp.dta 
// OUTPUT FILE - w_bmi_dv.dta

// WRITE FILEPATH WHERE YOU HAVE DOWNLOADED THE DATA
global in ""
// WRITE FILEPATH WHERE YOU WOULD LIKE TO SAVE THE OUTPUT FILE
global outpath ""



// 1 is for BHPS, 2 is for UKHLS
global cohort "2" 

foreach w in a { // INCLUDE WAVE LETTERS FOR THE WAVES NEEDED
global wave "`w'_"
global num=strpos("abcdefghijklmnopqrstuvwxyz","`w'")
global dta ""
global waveno=$num
global inpath "${in}/bhps_w${num}"
if $cohort==2 {
	global waveno=$num+18	
	global inpath "${in}/ukhls"
}


use "${inpath}/${wave}indresp${dta}", clear
drop *_bmi_dv

/* BMI is defined as body weight in kg divided by the square of the respondent’s 
   height in metres. Information on height and weight collected in imperial units 
   is converted to metric units. The BMI can be used to indicate whether an 
   individual is over or under weight using cut-off points as suggested, e.g., 
   by the WHO. We do not provide the categories.
*/

if ${waveno}==24 {
	ds *,not(type string)
	// recode -11 -10 to -8
	foreach v of varlist `r(varlist)' {
		recode `v' (. = -9)
		recode `v' (-11 -10 = -8)
		}	
	}
if ${cohort}==1 {
   cap rename ${wave}hlwtm ${wave}hlwt
}
isvar ${wave}hlhtf ${wave}hlhti ${wave}hlhtc ${wave}hlwt ${wave}hlwts ///
  ${wave}hlwtp ${wave}hlwtk ${wave}hlht
for var `r(varlist)': replace X=. if X<0


** Height, weight & BMI
generat double ${wave}heightCM=${wave}hlhtc if ${wave}hlhtc<. & ${wave}hlhtc>0
replace ${wave}heightCM=int(((${wave}hlhtf*12)+${wave}hlhti)*2.54) if ${wave}hlhtf!=. & ${wave}hlhti!=. 

su ${wave}heightCM if ${wave}hlht==1|${wave}hlht==2
su ${wave}heightCM if ${wave}hlht~=1 & ${wave}hlht~=2

generat double ${wave}weightKG=${wave}hlwtk if ${wave}hlwtk<. & ${wave}hlwtk>0
replace ${wave}weightKG=int(((${wave}hlwts*14)+${wave}hlwtp)*0.45359237) if ${wave}hlwts!=. & ${wave}hlwtp!=.

su ${wave}weightKG if ${wave}hlwt==1|${wave}hlwt==2
su ${wave}weightKG if ${wave}hlwt~=1 & ${wave}hlwt~=2

* markout ${wave}hlhtf ${wave}hlhti ${wave}hlhtc ${wave}hlwt ${wave}hlwts ${wave}hlwtp ${wave}hlwtk ${wave}hlht
gen double ${wave}bmi_dv=${wave}weightKG/((${wave}heightCM/100)^2)
replace ${wave}bmi_dv=round(${wave}bmi_dv,.1)
recode ${wave}bmi_dv (.=-9)
recode ${wave}bmi_dv (-9=-7) if ${wave}ivfio==2
lab def ${wave}bmi_dv -9"missing", replace
lab def ${wave}bmi_dv -7"proxy respondent", add
lab val ${wave}bmi_dv ${wave}bmi_dv
lab var ${wave}bmi_dv "Body Mass Index"
fre ${wave}bmi_dv
drop ${wave}weightKG ${wave}heightCM

keep pidp ${wave}bmi_dv
save "${outpath}/${wave}bmi_dv", replace
}

Email newsletter

Sign up to our newsletter

Enter your email to receive our newsletter updates.