Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • categorizing continuous data

    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

  • #2
    Welcome to Statalist.

    You have accidentally posted your topic in Statalist's Mata Forum, which is used for discussions of Stata's Mata language. Your question will see a much larger audience if you post it in Statalist's General Forum.

    Also, if you have not already done so, take a look at the Statalist FAQ linked to at the top of this page for posting guidelines and suggestions.

    With that said, though, you show that you gave the command
    Code:
    twoway histogram neo_birthwgt, start (1500) width (500) by ( bmiclass)
    I expect the command
    Code:
    twoway histogram neo_birthwgt, start (1500) width (500) by( bmiclass)
    will avoid that error - the space after the "by" is causing the problem, and the error message is, shall we say, neither helpful or accurate.

    Let me add that I would also remove the extra space after "start" and "width" just in case it is also a problem there.

    Comment

    Working...
    X