So I am trying to create BMI classes according to the WHO classification.
My database currently has BMI, HEIGHT (CM), Weight (KG) stored as string variables
So I decided to
The following code:
encode primarybmi, gen (NewBMI)
*Generating BMI groups*
gen BmiGroup = 0
replace BmiGroup = . if NewBMI ==.
replace BmiGroup = 1 if NewBMI <18.5
replace BmiGroup = 2 if NewBMI >=18.5 & NewBMI <=24.9
replace BmiGroup = 3 if NewBMI >=25.0 & NewBMI <=29.9
replace BmiGroup = 4 if NewBMI >=30.0 & NewBMI <=34.9
replace BmiGroup = 5 if NewBMI >=35.0 & NewBMI <=39.9
replace BmiGroup = 6 if NewBMI >=40 & !missing(NewBMI)
However, the problem I have values in the Bmigroup being incorrectly labelled as 6 when they don’t fall in the 6 category - they should for example be 4.
I don’t understand why this is happening.
I then tried to Calculate the BMI myself rather than use the database’s BMI so I tried this:
encode height, gen(NewHeight)
encode weight, gen(NewWeight)
generate Newbmi = NewWeight/ (NewHeight /100)^2
However, I have got values that do not make sense
eg. with
NewHeight: 173
NewWeight: 68
____
Newbmi: 285.66
This should read as 22.7
What am I doing wrong?
My database currently has BMI, HEIGHT (CM), Weight (KG) stored as string variables
So I decided to
- Encode and create BMI variable which I can work with and then convert into classes as per WHO..
The following code:
encode primarybmi, gen (NewBMI)
*Generating BMI groups*
gen BmiGroup = 0
replace BmiGroup = . if NewBMI ==.
replace BmiGroup = 1 if NewBMI <18.5
replace BmiGroup = 2 if NewBMI >=18.5 & NewBMI <=24.9
replace BmiGroup = 3 if NewBMI >=25.0 & NewBMI <=29.9
replace BmiGroup = 4 if NewBMI >=30.0 & NewBMI <=34.9
replace BmiGroup = 5 if NewBMI >=35.0 & NewBMI <=39.9
replace BmiGroup = 6 if NewBMI >=40 & !missing(NewBMI)
However, the problem I have values in the Bmigroup being incorrectly labelled as 6 when they don’t fall in the 6 category - they should for example be 4.
I don’t understand why this is happening.
I then tried to Calculate the BMI myself rather than use the database’s BMI so I tried this:
encode height, gen(NewHeight)
encode weight, gen(NewWeight)
generate Newbmi = NewWeight/ (NewHeight /100)^2
However, I have got values that do not make sense
eg. with
NewHeight: 173
NewWeight: 68
____
Newbmi: 285.66
This should read as 22.7
What am I doing wrong?
Comment