Announcement

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

  • Average mean of variables

    Please help
    in a situation where I have 6 variables (Proportion A - F)about various proportion.
    I want to create a new variable (a composite variable) on the average proportion of Proportion A - F.
    what do i do?

    eg.
    Proportion A (100%) Proportion B (100%) Proportion C (100%) Proportion D (100%) Proportion E (100%) Proportion F (100%) Average proportion X (100%)
    20 0 0 60 0 20
    0 50 10 10 10 20
    80 10 0 5 5 0
    10 10 10 30 20 20

  • #2
    those cannot be your real variable names as Stata does not allow spaces in variable names; please read and follow the FAQ advice on how to post; meanwhile, try
    Code:
    egen avgprop=rowmean(propA, etc.)
    where you replace avgprop with your chosen name and, more importantly, replace what is in parentheses with the actual names of the variables; see
    Code:
    h egen
    note that I have assumed your data are in wide format as implied above but that might not be true (another reason to post as per the FAQ)

    Comment


    • #3
      Rich Goldstein is spot on as usual. In addition, I note that if the row total is always 100% then the row mean is necessarily 100/6% to whatever number of decimal places you prefer. There would or could be exceptions whenever A to F are not the only constituents; whenever there are errors in the data; and possibly as a matter of rounding.

      Comment


      • #4
        thanks Rich Goldstein and Nick Cox.
        The data was reshaped from long format to wide format.
        What I'm trying to do is to create a composite variable to represent the average proportion per household id

        eg. this is the data after reshaping
        prop_a1 prop_a2 prop_a3 prop_a4 prop_a5 prop_a6
        5 10 0 0 0 0
        15 0 0 0 0 0
        5 10 0 0 0 0
        0 15 0 0 0 0
        0 15 0 0 0 0
        10 5 0 0 0 0
        0 0 10 5 0 0
        10 5 0 0 0 0
        5 5 5 0 0 0
        15 0 0 0 0 0

        Comment


        • #5
          #4 Fine by me. I was guided by your data example in which the row total is always 100%.

          I recommend this usage:

          proportions add to 1

          percents add to 100.

          Comment

          Working...
          X