Hello, I would be super grateful for some help with the following scenario

Maternal obesity is considered to influence birthweight of an infant, there is observational evidence to suggest that infants’ born to women with a high maternal BMI have a higher birthweight. This could be investigated by categorising the calculated
maternal pre-pregnancy BMI into obesity classes (I, II, III) and then comparing these three categories with infant birthweight. Obtain histograms for infant birthweight for the obesity classes. What is the Stata code? What do the results show?

I have used the following to categorise:

generate bmiclass=.
(1,000 missing values generated)

replace bmiclass = 1 if BMI>30 & BMI<35
(524 real changes made)


replace bmiclass = 2 if BMI>34 & BMI<39
(340 real changes made)

.replace bmiclass = 3 if BMI>39
(232 real changes made)


The issue is when I try to create a histogram- I get this message:

twoway histogram neo_birthwgt, start (1500) width (500) by ( bmiclass)
option by() not allowed

My query relates to how else I would produce a histogram of BMI class against infant birth weight

Thanks