Announcement

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

  • percent income shares for groups

    Hello All, how can I estimate percent shares of total income going to groups stored in a variable. For example, I have a variable called "income" and I have a variable called "groups". Groups stored in variable "groups" are Group1, Group2, etc. I want to estimate the percent of total income going to Group1, Group2, etc. I thought some option in *pshare* package may do it, but I have not found that option yet.

  • #2
    I can think of two set-ups consistent with #1 in the absence of a data example. If I have misunderstood your set-up and it is something else again, please give a data example explaining.

    Code:
    clear 
    input group income 
    1  10
    2  20
    3  30 
    end 
    
    egen double wanted1 = pc(income)
    
    list 
    
    clear 
    
    input id group income 
    1  1  4
    2  1  6
    3  2  8
    4  2  12
    5  3  6 
    6  3  7
    7  3  8
    8  3  9
    end 
    
    egen double group_total = total(income), by(group)
    su income, meanonly 
    gen double wanted2 = 100 * group_total / r(sum)
    
    list, sepby(group)
    Results

    +----------------------------+
    | group income wanted1 |
    |----------------------------|
    1. | 1 10 16.666667 |
    2. | 2 20 33.333333 |
    3. | 3 30 50 |
    +----------------------------+

    . +--------------------------------------------+
    | id group income group_~l wanted2 |
    |--------------------------------------------|
    1. | 1 1 4 10 16.666667 |
    2. | 2 1 6 10 16.666667 |
    |--------------------------------------------|
    3. | 3 2 8 20 33.333333 |
    4. | 4 2 12 20 33.333333 |
    |--------------------------------------------|
    5. | 5 3 6 30 50 |
    6. | 6 3 7 30 50 |
    7. | 7 3 8 30 50 |
    8. | 8 3 9 30 50 |
    +--------------------------------------------+

    [/CODE]

    Notes:

    1. The second solution would work for the first set-up.

    2. The use of doubles may be overkill, but you may have some very large (or very small) values to cope with.

    3. pshare is from the Stata Journal and updated from SSC, as you are asked to explain (FAQ Advice #12). It is an excellent command and I wouldn't be surprised if it can do this. Equally, these calculations are so basic that official commands should suffice.

    Comment

    Working...
    X