Announcement

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

  • How to generate household income from couple's individual income

    Hi, statalisters, I'm working on a research project which need to generate the variable represents the household income. I have each individual's income information and have identified the head(head==1) and spouse(spouse==1). Now, I decide to define the household income as head's income plus his/her spouse's income if head is married or head's income if he's unmarried. In this case, I cannot simply use some command like
    Code:
    bys hhid,egen hhincome=total(income)
    because there may be other members in the household who has income, like head's adault children who stay in living with their parents.So how can I achieve my goal, either using egen function or other approach? thank you.

  • #2
    Code:
    . bysort hhid: egen hhincome = total(income) if head==1 | spouse==1

    Comment


    • #3
      Originally posted by Svend Juul View Post
      Code:
      . bysort hhid: egen hhincome = total(income) if head==1 | spouse==1
      Thank you for reply, but I don't think it solve my problem,b/c it may (mistakely) add other member's income as I have mentioned.

      Comment


      • #4
        Originally posted by Zhang_Lu View Post
        Thank you for reply, but I don't think it solve my problem,b/c it may (mistakely) add other member's income as I have mentioned.
        It's difficult to grasp how it will mistakenly include other members while the condition provided by Svend is restricted to only head==1 or spouse==1 !! Probably you need provide a sample of your data to get the best help.
        Roman

        Comment


        • #5
          Cross-posted at http://stackoverflow.com/questions/2...ividual-income

          Please note our policy on cross-posting, which is that you should tell us about it. See FAQ Section 8.

          Comment


          • #6
            While Roman is correct that Svend's code will only include head and spouse incomes in the total, a limitation of that code is that the results will only appear in observations corresponding to head and spouse. If that household income information is also needed in observations of other household members, then either additional code is needed to spread those values over the entire household, or, generating them with the following code instead:

            Code:
            bysort hhid: egen hh_income = total(income*(head == 1 | spouse == 1))
            The above code will include in the total only the incomes of heads or spouses, but it will place the result in all observations for the household.

            Comment


            • #7
              Originally posted by Nick Cox View Post
              Cross-posted at http://stackoverflow.com/questions/2...ividual-income

              Please note our policy on cross-posting, which is that you should tell us about it. See FAQ Section 8.
              Ok,I shall note this issue, apologies for that

              Comment


              • #8
                Originally posted by Clyde Schechter View Post
                While Roman is correct that Svend's code will only include head and spouse incomes in the total, a limitation of that code is that the results will only appear in observations corresponding to head and spouse. If that household income information is also needed in observations of other household members, then either additional code is needed to spread those values over the entire household, or, generating them with the following code instead:

                Code:
                bysort hhid: egen hh_income = total(income*(head == 1 | spouse == 1))
                The above code will include in the total only the incomes of heads or spouses, but it will place the result in all observations for the household.
                That‘s of great help. Thanks Clyde

                Comment


                • #9
                  Hello all,
                  How do we calculate only spouse's income.? When I use bysort hhid: egen hh_income = total(income*(head == 1 | spouse == 1)) and then gen spouseincome=hh_income-income I end up with negative income values as individual's income . This is same if I want to calculate other household income excluding the individual herself. What might be the reason?

                  Comment


                  • #10
                    Originally posted by Clyde Schechter View Post
                    While Roman is correct that Svend's code will only include head and spouse incomes in the total, a limitation of that code is that the results will only appear in observations corresponding to head and spouse. If that household income information is also needed in observations of other household members, then either additional code is needed to spread those values over the entire household, or, generating them with the following code instead:

                    Code:
                    bysort hhid: egen hh_income = total(income*(head == 1 | spouse == 1))
                    The above code will include in the total only the incomes of heads or spouses, but it will place the result in all observations for the household.
                    How do we calculate only spouse's income.? When I use bysort hhid: egen hh_income = total(income*(head == 1 | spouse == 1)) and then gen spouseincome=hh_income-income I end up with negative income values as individual's income . This is same if I want to calculate other household income excluding the individual herself. That is
                    bysort hhid: egen hhincome = total(income*(head == 1 | spouse == 1 | child == 1))
                    gen other_hhincome= hhincome-income

                    What might be the reason for negative income? I notice that hh_income calculated by the code written by Clyde Schechter doesn't place the hh_income for all household members

                    Comment


                    • #11
                      It is not possible to answer your question without you providing example data. Use the -dataex- command to post back with example data that illustrates the problem you are encountering. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                      Comment


                      • #12
                        i have a similar question. i have the following information , i have individual incomes and i want to make a family income by grouping the indivuals income how is it done


                        ----------------------- copy starting from the next line -----------------------
                        [CODE]
                        * Example generated by -dataex-. To install: ssc install dataex
                        clear
                        input double(ID person_number) float income
                        3500 2 350
                        460 1 4500
                        93 3 1875
                        4361 2 1625
                        2385 1 8500
                        3088 2 2625
                        6995 1 850
                        9054 1 250
                        2277 2 1875
                        8928 1 750
                        2168 1 550
                        2175 2 550
                        3960 2 1375
                        3271 1 950
                        3046 1 550
                        1617 3 1625
                        7140 1 750
                        6683 1 8500
                        3970 1 1375
                        2545 1 550
                        2867 2 1375
                        1529 1 1625
                        3372 4 8500
                        2523 2 550
                        539 2 1125
                        7976 1 1375
                        8877 1 1625
                        7280 2 850
                        751 4 750
                        1757 2 850
                        6988 5 1875
                        8504 1 1375
                        8364 1 1375
                        4410 2 3875
                        3765 1 2375
                        3738 1 1875
                        6379 1 1625
                        4053 1 550
                        2271 2 550
                        5693 2 450
                        4789 3 350
                        2232 1 12500
                        6319 2 950
                        2382 1 1375
                        2123 2 50
                        7139 3 450
                        3268 1 750
                        3904 2 .
                        2619 1 750
                        2467 3 1375
                        6237 7 550
                        5158 11 350
                        3763 2 1875
                        8818 1 750
                        4645 3 950
                        5624 1 1375
                        1372 2 950
                        653 1 2125
                        1588 3 950
                        5097 1 2375
                        7309 1 550
                        4212 1 550
                        2514 2 2125
                        7545 4 1375
                        7590 1 50
                        7573 1 550
                        1269 1 550
                        244 2 3375
                        4277 3 950
                        6027 1 550
                        1782 3 550
                        553 2 1625
                        8821 2 650
                        1718 1 2625
                        599 4 450
                        2250 4 1125
                        8958 1 550
                        3134 2 250
                        940 1 550
                        66 2 1125
                        113 1 1625
                        4282 2 150
                        8477 4 850
                        1879 3 1875
                        3956 1 2125
                        3733 2 750
                        2382 2 2125
                        612 1 50
                        8026 1 50
                        2036 2 .
                        1996 1 650
                        7091 2 950
                        2102 1 550
                        6711 2 250
                        1447 1 950
                        6728 2 1625
                        1898 1 2875
                        8019 1 1375
                        2638 1 2875
                        2266 5 1375



                        Comment


                        • #13
                          Originally posted by KAYDEN MARLI View Post
                          i have a similar question. i have the following information , i have individual incomes and i want to make a family income by grouping the indivuals income how is it done


                          ----------------------- copy starting from the next line -----------------------
                          [CODE]
                          * Example generated by -dataex-. To install: ssc install dataex
                          clear
                          input double(ID person_number) float income
                          3500 2 350
                          460 1 4500
                          93 3 1875
                          4361 2 1625
                          2385 1 8500
                          3088 2 2625
                          6995 1 850
                          9054 1 250
                          2277 2 1875
                          8928 1 750
                          2168 1 550
                          2175 2 550
                          3960 2 1375
                          3271 1 950
                          3046 1 550
                          1617 3 1625
                          7140 1 750
                          6683 1 8500
                          3970 1 1375
                          2545 1 550
                          2867 2 1375
                          1529 1 1625
                          3372 4 8500
                          2523 2 550
                          539 2 1125
                          7976 1 1375
                          8877 1 1625
                          7280 2 850
                          751 4 750
                          1757 2 850
                          6988 5 1875
                          8504 1 1375
                          8364 1 1375
                          4410 2 3875
                          3765 1 2375
                          3738 1 1875
                          6379 1 1625
                          4053 1 550
                          2271 2 550
                          5693 2 450
                          4789 3 350
                          2232 1 12500
                          6319 2 950
                          2382 1 1375
                          2123 2 50
                          7139 3 450
                          3268 1 750
                          3904 2 .
                          2619 1 750
                          2467 3 1375
                          6237 7 550
                          5158 11 350
                          3763 2 1875
                          8818 1 750
                          4645 3 950
                          5624 1 1375
                          1372 2 950
                          653 1 2125
                          1588 3 950
                          5097 1 2375
                          7309 1 550
                          4212 1 550
                          2514 2 2125
                          7545 4 1375
                          7590 1 50
                          7573 1 550
                          1269 1 550
                          244 2 3375
                          4277 3 950
                          6027 1 550
                          1782 3 550
                          553 2 1625
                          8821 2 650
                          1718 1 2625
                          599 4 450
                          2250 4 1125
                          8958 1 550
                          3134 2 250
                          940 1 550
                          66 2 1125
                          113 1 1625
                          4282 2 150
                          8477 4 850
                          1879 3 1875
                          3956 1 2125
                          3733 2 750
                          2382 2 2125
                          612 1 50
                          8026 1 50
                          2036 2 .
                          1996 1 650
                          7091 2 950
                          2102 1 550
                          6711 2 250
                          1447 1 950
                          6728 2 1625
                          1898 1 2875
                          8019 1 1375
                          2638 1 2875
                          2266 5 1375


                          Code:
                          bys ID: egen family_incom = total(income)

                          Comment


                          • #14
                            thank u but i still get the same results...the incomes are not grouped

                            Comment


                            • #15
                              Originally posted by KAYDEN MARLI View Post
                              thank u but i still get the same results...the incomes are not grouped
                              Because for most families (in your example data), one family only has one member.

                              Comment

                              Working...
                              X