Announcement

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

  • Calculate mean from newly created variable

    Hello everyone,
    I'm new here to this forum and a newbe with Stata. I'm currently writing my thesis and already run into issues.
    . tab b05

    Age | Freq. Percent Cum.
    ------------+-----------------------------------
    10 | 41 7.12 7.12
    11 | 63 10.94 18.06
    12 | 46 7.99 26.04
    13 | 64 11.11 37.15
    14 | 74 12.85 50.00
    15 | 60 10.42 60.42
    16 | 65 11.28 71.70
    17 | 67 11.63 83.33
    18 | 60 10.42 93.75
    19 | 36 6.25 100.00
    ------------+-----------------------------------
    Total | 576 100.00

    I have dataset with a variable b05 that has adolescents in the age groups 10 to 19. Calculating the mean wasn't too hard but I also have to do this for 2 age categories. 10-14 and 15-19. I created with this code "egen age_catjo=cut(b05), at(10,15,22) icodes" the two categories and when I tabulate I see this:
    . tab age_catjo

    age_catjo | Freq. Percent Cum.
    ------------+-----------------------------------
    10-14 | 288 50.00 50.00
    15-19 | 288 50.00 100.00
    ------------+-----------------------------------
    Total | 576 100.00



    So far so good. But when I try to take the mean from this I get .5. How do I calculate the mean age in the two different age groups.
    Thanks in advance and I probably will have many more questions the coming weeks.

  • #2
    Code:
    su b05 if inrange(b05, 10, 14) 
    
    su b05 if inrange(b05, 15, 19)

    Comment


    • #3
      Thank you so much.

      Comment

      Working...
      X