Announcement

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

  • Keeping only households with one wife and one husband

    // Generating indicators for husband, wife, son, and daughter
    gen is_wife = (sex == 3 & (relationtohead == 1 | relationtohead == 2))
    gen is_husband = (sex == 1 & (relationtohead == 1 | relationtohead == 2))
    gen is_daughter = (sex == 3 & (relationtohead == 3 | relationtohead == 4))
    gen is_son = (sex == 1 & (relationtohead == 3 | relationtohead == 4))

    // Checking the number of husbands and wives in each household and wave
    bysort household_id wave: egen wives_per_wave = total(is_wife)
    bysort household_id wave: egen husbands_per_wave = total(is_husband)

    // Determining if there is at most one husband and one wife in each household
    bys household_id: egen max_husbands = max(husbands_per_wave)
    bys household_id: egen max_wives = max(wives_per_wave)
    bys household_id: gen unique_husband = (max_husbands == 1)
    bys household_id: gen unique_wife = (max_wives == 1)

    // Keeping households with at most one husband and one wife
    bys household_id: keep if unique_husband == 1 & unique_wife == 1

    However, although when browsing the data it appears that there is only when husband and one wife (across various waves) for each household, when I do:

    distinct pidlink if is_wife == 1 and distinct pidlink if is_husband == 1, I still get more wives than husbands (regardless of waves given the distinct command. Thus, implying, that I have kept households where more than one wife exists).

    I provide a data example below:

    clear
    input str10(household_id person_id) float(wave is_husband is_wife)
    "0010651" "001060004" 5 0 1
    "0010651" "001065102" 5 1 0
    "0010651" "001065103" 5 0 0
    "0010651" "001065104" 5 0 0
    "0010851" "001080003" 5 1 0
    "0010851" "001080012" 5 0 1
    "0010851" "001085103" 5 0 0
    "0010851" "001085104" 5 0 0
    "0010851" "001085105" 5 0 0
    "0010851" "001085106" 5 0 0
    "0010851" "001085107" 5 0 0
    "0012200" "001220001" 1 1 0
    "0012200" "001220001" 2 1 0
    "0012200" "001220001" 3 1 0
    "0012200" "001220001" 4 1 0
    "0012200" "001220001" 5 1 0
    "0012200" "001220002" 1 0 1
    "0012200" "001220002" 2 0 1
    "0012200" "001220002" 3 0 1
    "0012200" "001220002" 4 0 1
    "0012200" "001220002" 5 0 1
    "0012200" "001220003" 1 0 0
    "0012200" "001220003" 2 0 0
    "0012200" "001220003" 3 0 0
    "0012241" "001220003" 4 1 0
    "0012241" "001220003" 5 1 0
    "0012200" "001220004" 1 0 0
    "0012200" "001220004" 2 0 0
    "0012200" "001220004" 3 0 0
    "0012200" "001220004" 4 0 0
    "0012200" "001220004" 5 0 0
    "0012200" "001220005" 1 0 0
    "0012200" "001220005" 2 0 0
    "0012200" "001220005" 3 0 0
    "0012200" "001220005" 4 0 0
    "0012200" "001220005" 5 0 0
    "0012200" "001220006" 1 0 0
    "0012200" "001220006" 2 0 0
    "0012200" "001220006" 3 0 0
    "0012200" "001220006" 4 0 0
    "0012200" "001220006" 5 0 0
    "0012200" "001220007" 1 0 0
    "0012200" "001220007" 2 0 0
    "0012200" "001220007" 3 0 0
    "0012200" "001220007" 4 0 0
    "0012200" "001220007" 5 0 0
    "0012200" "001220008" 1 0 0
    "0012200" "001220008" 2 0 0
    "0012200" "001220008" 3 0 0
    "0012200" "001220009" 1 0 0
    "0012200" "001220009" 2 0 0
    "0012200" "001220009" 3 0 0
    "0012200" "001220009" 4 0 0
    "0012200" "001220010" 1 0 0
    "0012200" "001220010" 2 0 0
    "0012200" "001220010" 3 0 0
    "0012200" "001220010" 4 0 0
    "0012200" "001220010" 5 0 0
    "0012241" "001220011" 4 0 1
    "0012241" "001220011" 5 0 1
    "0012241" "001220013" 4 0 0
    "0012241" "001220013" 5 0 0
    "0012200" "001220014" 4 0 0
    "0012200" "001220014" 5 0 0
    "0012200" "001220015" 4 0 0
    "0012200" "001220015" 5 0 0
    "0012241" "001224104" 4 0 0
    "0012241" "001224104" 5 0 0
    "0012241" "001224105" 4 0 0
    "0012241" "001224105" 5 0 0
    "0012241" "001224106" 5 0 0
    "0012400" "001240001" 1 1 0
    "0012400" "001240001" 2 1 0
    "0012400" "001240001" 5 1 0
    "0012400" "001240002" 1 0 1
    "0012400" "001240002" 2 0 1
    "0012400" "001240002" 5 0 1
    "0012400" "001240003" 1 0 0
    "0012400" "001240003" 2 0 0
    "0012400" "001240003" 5 0 0
    "0012400" "001240004" 1 0 0
    "0012400" "001240004" 2 0 0
    "0012400" "001240004" 5 0 0
    "0012400" "001240005" 1 0 0
    "0012400" "001240005" 2 0 0
    "0012451" "001240005" 5 0 1
    "0012400" "001240006" 1 0 0
    "0012400" "001240006" 2 0 0
    "0012400" "001240006" 5 0 0
    "0012400" "001240007" 1 0 0
    "0012400" "001240007" 2 0 0
    "0012400" "001240007" 5 0 0
    "0012400" "001240008" 1 0 0
    "0012400" "001240008" 2 0 0
    "0012400" "001240008" 5 0 0
    "0012400" "001240009" 1 0 0
    "0012400" "001240009" 2 0 0
    "0012452" "001240009" 5 0 1
    "0012400" "001240010" 1 0 0
    "0012400" "001240010" 2 0 0

    Thank you in advance,

    Enrique

  • #2
    Hi Enrique,

    Thank you for supplying some sample data.

    Code:
    list if inlist(household, "0012451", "0012452")
    produces the following, indicating that your sample data contain two household-wave pairs where there is a wife but no husband.

    Code:
         +--------------------------------------------------+
         | househ~d   person_id   wave   is_hus~d   is_wife |
         |--------------------------------------------------|
     86. |  0012451   001240005      5          0         1 |
     98. |  0012452   001240009      5          0         1 |
         +--------------------------------------------------+
    When I run the following part of your code those two observations are dropped. Note that they satisfy the condition in the comment -- "at most one husband and one wife"-- though not the condition "exactly one husband and one wife" your code appears to check for.

    Code:
    // Checking the number of husbands and wives in each household and wave
    bysort household_id wave: egen wives_per_wave = total(is_wife)
    bysort household_id wave: egen husbands_per_wave = total(is_husband)
    
    // Determining if there is at most one husband and one wife in each household
    bys household_id: egen max_husbands = max(husbands_per_wave)
    bys household_id: egen max_wives = max(wives_per_wave)
    bys household_id: gen unique_husband = (max_husbands == 1)
    bys household_id: gen unique_wife = (max_wives == 1)
    
    bys household_id: keep if unique_husband == 1 & unique_wife == 1
    pidlink is not defined, so I can't comment on that part of your code.

    Devra Golbe
    Professor Emerita, Dept. of Economics
    Hunter College, CUNY

    Comment


    • #3
      drop if state=="Utah"

      Comment


      • #4
        Originally posted by Devra Golbe View Post
        Hi Enrique,

        Thank you for supplying some sample data.

        Code:
        list if inlist(household, "0012451", "0012452")
        produces the following, indicating that your sample data contain two household-wave pairs where there is a wife but no husband.

        Code:
        +--------------------------------------------------+
        | househ~d person_id wave is_hus~d is_wife |
        |--------------------------------------------------|
        86. | 0012451 001240005 5 0 1 |
        98. | 0012452 001240009 5 0 1 |
        +--------------------------------------------------+
        When I run the following part of your code those two observations are dropped. Note that they satisfy the condition in the comment -- "at most one husband and one wife"-- though not the condition "exactly one husband and one wife" your code appears to check for.

        Code:
        // Checking the number of husbands and wives in each household and wave
        bysort household_id wave: egen wives_per_wave = total(is_wife)
        bysort household_id wave: egen husbands_per_wave = total(is_husband)
        
        // Determining if there is at most one husband and one wife in each household
        bys household_id: egen max_husbands = max(husbands_per_wave)
        bys household_id: egen max_wives = max(wives_per_wave)
        bys household_id: gen unique_husband = (max_husbands == 1)
        bys household_id: gen unique_wife = (max_wives == 1)
        
        bys household_id: keep if unique_husband == 1 & unique_wife == 1
        pidlink is not defined, so I can't comment on that part of your code.
        Hi Devra,

        Thank you so much for your help. Pidlink is actually person_id in the data example. Do you know how I could change the code to exactly one husband and one wife?

        Thanks a lot,

        Enrique

        Comment


        • #5
          Code:
          bys household wave: egen husbandwife = total(is_husband + is_wife)
          looking for a 2

          Comment


          • #6
            Originally posted by George Ford View Post
            Code:
            bys household wave: egen husbandwife = total(is_husband + is_wife)
            looking for a 2
            Hi George,

            Thanks a lot, this is a smart and elegant solution.

            However, some wives appear in certain waves where husbands do not (although both are present in the household). This causes the "distinct pidlink if is_husband == 1" to yield slightly different distinct values to "distinct pidlink if is_wife == 1" (i.e., there are still slightly more wives than husbands) upon keeping instances where husbandwife == 2. Do you know how I can fix this?

            Thanks a lot,

            Enrique.
            Last edited by Enrique Alameda; 23 Jan 2025, 15:43.

            Comment


            • #7
              Enrique,

              I think your code gives exactly one husband and one wife. Indeed, when I run George's code after the code I quoted in my post husbandwife =2 for all observations. And when I run

              Code:
              distinct person_id if is_wife == 1
              distinct person_id if is_husb == 1
              I get identical results from each command.

              Perhaps you need to supply a different sample of observations in order to illustrate the issues you are having.

              Devra Golbe
              Professor Emerita, Dept. of Economics
              Hunter College, CUNY

              Comment


              • #8
                Originally posted by Devra Golbe View Post
                Enrique,

                I think your code gives exactly one husband and one wife. Indeed, when I run George's code after the code I quoted in my post husbandwife =2 for all observations. And when I run

                Code:
                distinct person_id if is_wife == 1
                distinct person_id if is_husb == 1
                I get identical results from each command.

                Perhaps you need to supply a different sample of observations in order to illustrate the issues you are having.
                Hi Devra and George,

                Here is a data example prior to running mine or George's code. I have changed notation to make it easier to understand:

                clear
                input str10(pidlink hhid) float(wave husband wife)
                "272010001" "2720100" 1 1 0
                "272010001" "2720100" 2 1 0
                "272010001" "2720100" 3 1 0
                "272010001" "2720100" 4 1 0
                "272010001" "2720100" 5 1 0
                "272010002" "2720100" 1 0 1
                "272010002" "2720100" 2 0 1
                "272010002" "2720100" 3 0 1
                "272010002" "2720100" 4 0 1
                "272010002" "2720151" 5 0 0
                "272010003" "2720100" 1 0 0
                "272010003" "2720100" 2 0 0
                "272010003" "2720100" 3 0 0
                "272010003" "2720100" 4 0 0
                "272010003" "2720100" 5 0 0
                "272010004" "2720100" 2 0 0
                "272010004" "2720100" 3 0 0
                "272010004" "2720100" 4 0 0
                "272010004" "2720100" 5 0 0
                "272010005" "2720100" 5 0 0
                "272010006" "2720100" 5 0 1
                "272020001" "2720200" 1 1 0
                "272020001" "2720211" 2 1 0
                "272020001" "2720211" 3 1 0
                "272020001" "2720211" 4 1 0
                "272020001" "2720211" 5 1 0
                "272020002" "2720200" 1 0 1
                "272020002" "2720211" 2 0 1
                "272020002" "2720211" 3 0 1
                "272020002" "2720211" 4 0 1
                "272020002" "2720211" 5 0 1
                "272020003" "2720200" 1 0 0
                "272020003" "2720211" 2 0 0
                "272020003" "2720211" 3 0 0
                "272020003" "2720211" 4 0 0
                "272020003" "2720211" 5 0 0
                "272020004" "2720200" 2 1 0
                "272020004" "2720200" 3 1 0
                "272020004" "2720200" 4 1 0
                "272020004" "2720200" 5 1 0
                "272020005" "2720200" 2 0 1
                "272020005" "2720200" 3 0 1
                "272020005" "2720200" 4 0 1
                "272020005" "2720200" 5 0 0
                "272021104" "2720211" 2 0 0
                "272021104" "2720211" 3 0 0
                "272021104" "2720211" 4 0 0
                "272021104" "2720211" 5 0 0
                "272030001" "2720300" 1 1 0
                "272030001" "2720300" 2 1 0
                "272030001" "2720300" 3 1 0
                "272030001" "2720300" 4 1 0
                "272030001" "2720300" 5 1 0
                "272030002" "2720300" 1 0 1
                "272030002" "2720300" 2 0 1
                "272030002" "2720300" 3 0 1
                "272030002" "2720300" 4 0 1
                "272030002" "2720300" 5 0 1
                "272030003" "2720300" 1 0 0
                "272030003" "2720300" 2 0 0
                "272030003" "2720300" 3 0 0
                "272030003" "2720341" 4 0 1
                "272030004" "2720300" 2 0 0
                "272030004" "2720300" 3 0 0
                "272030004" "2720300" 4 0 0
                "272030004" "2720300" 5 0 0
                "272030005" "2720300" 3 0 0
                "272030005" "2720300" 4 0 0
                "272030005" "2720300" 5 0 0
                "272034101" "2720341" 4 1 0
                "272034101" "2720341" 5 0 0
                "272034103" "2720341" 4 0 0
                "272034104" "2720341" 5 1 0
                "272040001" "2720400" 1 1 0
                "272040001" "2720400" 2 1 0
                "272040001" "2720400" 3 1 0
                "272040001" "2720400" 4 1 0
                "272040001" "2720400" 5 1 0
                "272040002" "2720400" 1 0 1
                "272040002" "2720400" 2 0 1
                "272040002" "2720400" 3 0 1
                "272040002" "2720400" 4 0 1
                "272040002" "2720400" 5 0 1
                "272040003" "2720400" 1 0 0
                "272040003" "2720400" 2 0 0
                "272040003" "2720400" 3 0 0
                "272040003" "2720400" 4 0 0
                "272040003" "2720451" 5 1 0
                "272040004" "2720400" 1 0 0
                "272040004" "2720400" 2 0 0
                "272040004" "2720400" 3 0 0
                "272040004" "2720400" 4 0 0
                "272040004" "2720400" 5 0 0
                "272040005" "2720400" 4 0 0
                "272040005" "2720400" 5 0 0
                "272050001" "2720500" 1 1 0
                "272050001" "2720500" 2 1 0
                "272050001" "2720500" 3 1 0
                "272050001" "2720500" 4 1 0
                "272050001" "2720500" 5 1 0
                end


                Upon running the code, if I do:

                keep if husbandwife == 2
                (41,234 observations deleted)

                And then the distinct:

                . distinct pidlink if wife == 1

                | Observations
                | total distinct
                ---------+----------------------
                pidlink | 39619 15910

                . distinct pidlink if husband == 1

                | Observations
                | total distinct
                ---------+----------------------
                pidlink | 40025 16008



                As you can see there is a different number of husband and wives. I provide a data example following this step below:

                clear
                input str10(pidlink hhid) float(wave husband wife)
                "001060005" "0010600" 1 0 0
                "001060006" "0010600" 1 0 0
                "001060001" "0010600" 1 1 0
                "001060002" "0010600" 1 0 1
                "001060004" "0010600" 1 0 0
                "001060003" "0010600" 1 0 0
                "001060004" "0010600" 2 0 0
                "001060002" "0010600" 2 0 1
                "001060006" "0010600" 2 0 0
                "001060005" "0010600" 2 0 0
                "001060003" "0010600" 2 0 0
                "001060001" "0010600" 2 1 0
                "001065104" "0010651" 5 0 0
                "001060004" "0010651" 5 0 1
                "001065102" "0010651" 5 1 0
                "001065103" "0010651" 5 0 0
                "001080008" "0010800" 1 0 0
                "001080006" "0010800" 1 0 0
                "001080003" "0010800" 1 0 0
                "001080005" "0010800" 1 0 0
                "001080007" "0010800" 1 0 0
                "001080009" "0010800" 1 0 0
                "001080002" "0010800" 1 0 1
                "001080010" "0010800" 1 0 0
                "001080004" "0010800" 1 0 0
                "001080001" "0010800" 1 1 0
                "001080009" "0010800" 2 0 0
                "001080008" "0010800" 2 0 0
                "001080010" "0010800" 2 0 0
                "001080001" "0010800" 2 1 0
                "001080004" "0010800" 2 0 0
                "001080006" "0010800" 2 0 0
                "001080005" "0010800" 2 0 0
                "001080003" "0010800" 2 0 0
                "001080007" "0010800" 2 0 0
                "001080002" "0010800" 2 0 1
                "001085107" "0010851" 5 0 0
                "001085104" "0010851" 5 0 0
                "001085105" "0010851" 5 0 0
                "001080012" "0010851" 5 0 1
                "001080003" "0010851" 5 1 0
                "001085106" "0010851" 5 0 0
                "001085103" "0010851" 5 0 0
                "001220009" "0012200" 1 0 0
                "001220008" "0012200" 1 0 0
                "001220002" "0012200" 1 0 1
                "001220001" "0012200" 1 1 0
                "001220003" "0012200" 1 0 0
                "001220004" "0012200" 1 0 0
                "001220006" "0012200" 1 0 0
                "001220005" "0012200" 1 0 0
                "001220010" "0012200" 1 0 0
                "001220007" "0012200" 1 0 0
                "001220010" "0012200" 2 0 0
                "001220001" "0012200" 2 1 0
                "001220004" "0012200" 2 0 0
                "001220002" "0012200" 2 0 1
                "001220008" "0012200" 2 0 0
                "001220006" "0012200" 2 0 0
                "001220009" "0012200" 2 0 0
                "001220007" "0012200" 2 0 0
                "001220005" "0012200" 2 0 0
                "001220003" "0012200" 2 0 0
                "001220009" "0012200" 3 0 0
                "001220002" "0012200" 3 0 1
                "001220003" "0012200" 3 0 0
                "001220007" "0012200" 3 0 0
                "001220001" "0012200" 3 1 0
                "001220005" "0012200" 3 0 0
                "001220008" "0012200" 3 0 0
                "001220010" "0012200" 3 0 0
                "001220006" "0012200" 3 0 0
                "001220004" "0012200" 3 0 0
                "001220004" "0012200" 4 0 0
                "001220007" "0012200" 4 0 0
                "001220006" "0012200" 4 0 0
                "001220001" "0012200" 4 1 0
                "001220005" "0012200" 4 0 0
                "001220009" "0012200" 4 0 0
                "001220002" "0012200" 4 0 1
                "001220014" "0012200" 4 0 0
                "001220015" "0012200" 4 0 0
                "001220010" "0012200" 4 0 0
                "001220004" "0012200" 5 0 0
                "001220006" "0012200" 5 0 0
                "001220007" "0012200" 5 0 0
                "001220014" "0012200" 5 0 0
                "001220002" "0012200" 5 0 1
                "001220005" "0012200" 5 0 0
                "001220015" "0012200" 5 0 0
                "001220001" "0012200" 5 1 0
                "001220010" "0012200" 5 0 0
                "001220003" "0012241" 4 1 0
                "001224104" "0012241" 4 0 0
                "001224105" "0012241" 4 0 0
                "001220011" "0012241" 4 0 1
                "001220013" "0012241" 4 0 0
                "001220003" "0012241" 5 1 0
                "001220013" "0012241" 5 0 0
                "001224105" "0012241" 5 0 0
                end
                [/CODE]


                I am grateful for any help, as I cannot comprehend my mistake.

                Thank you in advance,

                ​​​​​​​Enrique

                Comment


                • #9
                  I get the same with this.
                  Code:
                  bys hhid wave: egen husbandwife = total(husband + wife)
                  
                  . keep if husbandwife==2
                  (3 observations deleted)
                  
                  . 
                  . distinct pidlink if wife == 1
                  
                  
                  total   distinct
                  
                  pidlink         12          6
                  
                  
                  . distinct pidlink if husband ==    1
                  
                  
                  total   distinct
                  
                  pidlink         12          6
                  
                  
                  . 
                  . distinct hhid if wife == 1
                  
                  
                  total   distinct
                  
                  hhid         12          6
                  
                  
                  . distinct hhid if husband == 1
                  
                  
                  total   distinct
                  
                  hhid         12          6

                  Comment


                  • #10
                    If the problem is missing data, then any solution is going to be a bit of a kluge.

                    One option is to assume that if it's 2 2 1 2 2, then it should be a 2 in between due to missing values. I'd have more confidence if the household member count followed the same pattern.

                    Code:
                    bys hhid wave: egen hhsize = count(hhid)

                    Comment


                    • #11
                      Originally posted by George Ford View Post
                      If the problem is missing data, then any solution is going to be a bit of a kluge.

                      One option is to assume that if it's 2 2 1 2 2, then it should be a 2 in between due to missing values. I'd have more confidence if the household member count followed the same pattern.

                      Code:
                      bys hhid wave: egen hhsize = count(hhid)
                      Hi George,

                      Thanks a lot for all your help.

                      Here is the output from your code. Note that the dataset also contains sons and daughters of these couples (i.e., to identify child-wife pairs):

                      bys hhid wave: egen hhsize = count(hhid)

                      .
                      end of do-file

                      . ta hhsize

                      hhsize | Freq. Percent Cum.
                      ------------+-----------------------------------
                      2 | 10,314 5.96 5.96
                      3 | 34,371 19.88 25.84
                      4 | 48,292 27.93 53.77
                      5 | 36,365 21.03 74.80
                      6 | 21,594 12.49 87.28
                      7 | 11,137 6.44 93.72
                      8 | 6,056 3.50 97.23
                      9 | 2,943 1.70 98.93
                      10 | 1,160 0.67 99.60
                      11 | 495 0.29 99.88
                      12 | 132 0.08 99.96
                      13 | 52 0.03 99.99
                      15 | 15 0.01 100.00
                      ------------+-----------------------------------
                      Total | 172,926 100.00



                      Comment


                      • #12
                        This might get you started. I've dropped the middle observation of wife for hhid==0012200 to create some interest.

                        I think the kids condition may be redundant in markreplace.

                        The math to address a change in kids should be easy enough to implement, but this might tell you how big the problem is.

                        Code:
                        clear
                        input str10(pidlink hhid) float(wave husband wife)
                        "001060005" "0010600" 1 0 0
                        "001060006" "0010600" 1 0 0
                        "001060001" "0010600" 1 1 0
                        "001060002" "0010600" 1 0 1
                        "001060004" "0010600" 1 0 0
                        "001060003" "0010600" 1 0 0
                        "001060004" "0010600" 2 0 0
                        "001060002" "0010600" 2 0 1
                        "001060006" "0010600" 2 0 0
                        "001060005" "0010600" 2 0 0
                        "001060003" "0010600" 2 0 0
                        "001060001" "0010600" 2 1 0
                        "001065104" "0010651" 5 0 0
                        "001060004" "0010651" 5 0 1
                        "001065102" "0010651" 5 1 0
                        "001065103" "0010651" 5 0 0
                        "001080008" "0010800" 1 0 0
                        "001080006" "0010800" 1 0 0
                        "001080003" "0010800" 1 0 0
                        "001080005" "0010800" 1 0 0
                        "001080007" "0010800" 1 0 0
                        "001080009" "0010800" 1 0 0
                        "001080002" "0010800" 1 0 1
                        "001080010" "0010800" 1 0 0
                        "001080004" "0010800" 1 0 0
                        "001080001" "0010800" 1 1 0
                        "001080009" "0010800" 2 0 0
                        "001080008" "0010800" 2 0 0
                        "001080010" "0010800" 2 0 0
                        "001080001" "0010800" 2 1 0
                        "001080004" "0010800" 2 0 0
                        "001080006" "0010800" 2 0 0
                        "001080005" "0010800" 2 0 0
                        "001080003" "0010800" 2 0 0
                        "001080007" "0010800" 2 0 0
                        "001080002" "0010800" 2 0 1
                        "001085107" "0010851" 5 0 0
                        "001085104" "0010851" 5 0 0
                        "001085105" "0010851" 5 0 0
                        "001080012" "0010851" 5 0 1
                        "001080003" "0010851" 5 1 0
                        "001085106" "0010851" 5 0 0
                        "001085103" "0010851" 5 0 0
                        "001220009" "0012200" 1 0 0
                        "001220008" "0012200" 1 0 0
                        "001220002" "0012200" 1 0 1
                        "001220001" "0012200" 1 1 0
                        "001220003" "0012200" 1 0 0
                        "001220004" "0012200" 1 0 0
                        "001220006" "0012200" 1 0 0
                        "001220005" "0012200" 1 0 0
                        "001220010" "0012200" 1 0 0
                        "001220007" "0012200" 1 0 0
                        "001220010" "0012200" 2 0 0
                        "001220001" "0012200" 2 1 0
                        "001220004" "0012200" 2 0 0
                        "001220002" "0012200" 2 0 1
                        "001220008" "0012200" 2 0 0
                        "001220006" "0012200" 2 0 0
                        "001220009" "0012200" 2 0 0
                        "001220007" "0012200" 2 0 0
                        "001220005" "0012200" 2 0 0
                        "001220003" "0012200" 2 0 0
                        "001220009" "0012200" 3 0 0
                        /*"001220002" "0012200" 3 0 1*/
                        "001220003" "0012200" 3 0 0
                        "001220007" "0012200" 3 0 0
                        "001220001" "0012200" 3 1 0
                        "001220005" "0012200" 3 0 0
                        "001220008" "0012200" 3 0 0
                        "001220010" "0012200" 3 0 0
                        "001220006" "0012200" 3 0 0
                        "001220004" "0012200" 3 0 0
                        "001220004" "0012200" 4 0 0
                        "001220007" "0012200" 4 0 0
                        "001220006" "0012200" 4 0 0
                        "001220001" "0012200" 4 1 0
                        "001220005" "0012200" 4 0 0
                        "001220009" "0012200" 4 0 0
                        "001220002" "0012200" 4 0 1
                        "001220014" "0012200" 4 0 0
                        "001220015" "0012200" 4 0 0
                        "001220010" "0012200" 4 0 0
                        "001220004" "0012200" 5 0 0
                        "001220006" "0012200" 5 0 0
                        "001220007" "0012200" 5 0 0
                        "001220014" "0012200" 5 0 0
                        "001220002" "0012200" 5 0 1
                        "001220005" "0012200" 5 0 0
                        "001220015" "0012200" 5 0 0
                        "001220001" "0012200" 5 1 0
                        "001220010" "0012200" 5 0 0
                        "001220003" "0012241" 4 1 0
                        "001224104" "0012241" 4 0 0
                        "001224105" "0012241" 4 0 0
                        "001220011" "0012241" 4 0 1
                        "001220013" "0012241" 4 0 0
                        "001220003" "0012241" 5 1 0
                        "001220013" "0012241" 5 0 0
                        "001224105" "0012241" 5 0 0
                        end
                        
                        bys hhid wave: egen husbandwife = total(husband + wife)
                        bys hhid wave: egen hhsize = count(hhid)
                        g kids = hhsize - husbandwife
                        
                        bys hhid: egen max_husbandwife = max(husbandwife)
                        keep if max_husbandwife==2 // delete cases not desired
                        
                        bys hhid: egen max_hhsize = max(hhsize)
                        bys hhid: egen max_kids = max(kids)
                        bys hhid: egen min_wave = min(wave)
                        bys hhid: egen max_wave = max(wave)
                        
                        g markreplace = (husbandwife - max_husbandwife)==-1 & (hhsize - max_hhsize)==-1 & (kids==max_kids) & (wave != min_wave) & (wave != !max_wave)
                        * wave included as condition since you don't have data to either side to confirm.
                        g markcheck = (husbandwife - max_husbandwife)==-1 & (hhsize - max_hhsize)==-1 & (kids!=max_kids)
                        replace husbandwife = 2 if markreplace

                        Comment


                        • #13
                          Enrique,

                          The data sample you provide cannot be the data sample on which you ran your code (> 40,000 observations deleted.) Try to extract a small set of data which produces the phenomenon that concerns you: more distinct wives than husbands.

                          I suspect also that you will get better answers if you describe your data more fully. I guess that you are using some kind of household sample which is resurveyed multiple times (waves.) I don't know anything about this sample-- even how a household is defined. I would not be surprised if the number of children changes over time in the same HH ID. But suppose a head of household changes spouses. Does the HH ID change or stay the same? If the spouse who is not designated head of HH gets a new spouse does he drop out of the survey or get a new HH ID? I'm not certain, given the possible changes in HH composition, whether the numbers of distinct husbands & wives should be the same.
                          Devra Golbe
                          Professor Emerita, Dept. of Economics
                          Hunter College, CUNY

                          Comment


                          • #14
                            Originally posted by Devra Golbe View Post
                            Enrique,

                            The data sample you provide cannot be the data sample on which you ran your code (> 40,000 observations deleted.) Try to extract a small set of data which produces the phenomenon that concerns you: more distinct wives than husbands.

                            I suspect also that you will get better answers if you describe your data more fully. I guess that you are using some kind of household sample which is resurveyed multiple times (waves.) I don't know anything about this sample-- even how a household is defined. I would not be surprised if the number of children changes over time in the same HH ID. But suppose a head of household changes spouses. Does the HH ID change or stay the same? If the spouse who is not designated head of HH gets a new spouse does he drop out of the survey or get a new HH ID? I'm not certain, given the possible changes in HH composition, whether the numbers of distinct husbands & wives should be the same.
                            Hi George and Devra,

                            Thank you very much once again.

                            Please find below a subset of the actual data that produces the problem. Previously I was using dataex, which may not have reproduced the actual dataset well. Now I list 348 observations of the variables. Please find these below:

                            The dataset refers to a household survey where members are interviewed based on the relationship to the head of the household, in a context where husbands may have more than one wife. If a household head changes spouses, then that person is interviewed in the following wave and shows up with a new pidlink. If a daughter interviewed in a given wave gets married, becomes a wife and moves out of the household, she is re-interviewed keeping the same pidlink but a new hhid. Does this help?


                            +---------------------------------------------+
                            | pidlink hhid wave husband wife |
                            |---------------------------------------------|
                            1. | 001060001 0010600 1 1 0 |
                            2. | 001060001 0010600 2 1 0 |
                            3. | 001060002 0010600 1 0 1 |
                            4. | 001060002 0010600 2 0 1 |
                            5. | 001060003 0010600 1 0 0 |
                            |---------------------------------------------|
                            6. | 001060003 0010600 2 0 0 |
                            7. | 001060004 0010600 1 0 0 |
                            8. | 001060004 0010600 2 0 0 |
                            9. | 001060004 0010651 5 0 1 |
                            10. | 001060005 0010600 1 0 0 |
                            |---------------------------------------------|
                            11. | 001060005 0010600 2 0 0 |
                            12. | 001060006 0010600 1 0 0 |
                            13. | 001060006 0010600 2 0 0 |
                            14. | 001065102 0010651 5 1 0 |
                            15. | 001065103 0010651 5 0 0 |
                            |---------------------------------------------|
                            16. | 001065104 0010651 5 0 0 |
                            17. | 001080001 0010800 1 1 0 |
                            18. | 001080001 0010800 2 1 0 |
                            19. | 001080002 0010800 1 0 1 |
                            20. | 001080002 0010800 2 0 1 |
                            |---------------------------------------------|
                            21. | 001080003 0010800 1 0 0 |
                            22. | 001080003 0010800 2 0 0 |
                            23. | 001080003 0010851 5 1 0 |
                            24. | 001080004 0010800 1 0 0 |
                            25. | 001080004 0010800 2 0 0 |
                            |---------------------------------------------|
                            26. | 001080005 0010800 1 0 0 |
                            27. | 001080005 0010800 2 0 0 |
                            28. | 001080006 0010800 1 0 0 |
                            29. | 001080006 0010800 2 0 0 |
                            30. | 001080007 0010800 1 0 0 |
                            |---------------------------------------------|
                            31. | 001080007 0010800 2 0 0 |
                            32. | 001080008 0010800 1 0 0 |
                            33. | 001080008 0010800 2 0 0 |
                            34. | 001080009 0010800 1 0 0 |
                            35. | 001080009 0010800 2 0 0 |
                            |---------------------------------------------|
                            36. | 001080010 0010800 1 0 0 |
                            37. | 001080010 0010800 2 0 0 |
                            38. | 001080012 0010851 5 0 1 |
                            39. | 001085103 0010851 5 0 0 |
                            40. | 001085104 0010851 5 0 0 |
                            |---------------------------------------------|
                            41. | 001085105 0010851 5 0 0 |
                            42. | 001085106 0010851 5 0 0 |
                            43. | 001085107 0010851 5 0 0 |
                            44. | 001220001 0012200 1 1 0 |
                            45. | 001220001 0012200 2 1 0 |
                            |---------------------------------------------|
                            46. | 001220001 0012200 3 1 0 |
                            47. | 001220001 0012200 4 1 0 |
                            48. | 001220001 0012200 5 1 0 |
                            49. | 001220002 0012200 1 0 1 |
                            50. | 001220002 0012200 2 0 1 |
                            |---------------------------------------------|
                            51. | 001220002 0012200 3 0 1 |
                            52. | 001220002 0012200 4 0 1 |
                            53. | 001220002 0012200 5 0 1 |
                            54. | 001220003 0012200 1 0 0 |
                            55. | 001220003 0012200 2 0 0 |
                            |---------------------------------------------|
                            56. | 001220003 0012200 3 0 0 |
                            57. | 001220003 0012241 4 1 0 |
                            58. | 001220003 0012241 5 1 0 |
                            59. | 001220004 0012200 1 0 0 |
                            60. | 001220004 0012200 2 0 0 |
                            |---------------------------------------------|
                            61. | 001220004 0012200 3 0 0 |
                            62. | 001220004 0012200 4 0 0 |
                            63. | 001220004 0012200 5 0 0 |
                            64. | 001220005 0012200 1 0 0 |
                            65. | 001220005 0012200 2 0 0 |
                            |---------------------------------------------|
                            66. | 001220005 0012200 3 0 0 |
                            67. | 001220005 0012200 4 0 0 |
                            68. | 001220005 0012200 5 0 0 |
                            69. | 001220006 0012200 1 0 0 |
                            70. | 001220006 0012200 2 0 0 |
                            |---------------------------------------------|
                            71. | 001220006 0012200 3 0 0 |
                            72. | 001220006 0012200 4 0 0 |
                            73. | 001220006 0012200 5 0 0 |
                            74. | 001220007 0012200 1 0 0 |
                            75. | 001220007 0012200 2 0 0 |
                            |---------------------------------------------|
                            76. | 001220007 0012200 3 0 0 |
                            77. | 001220007 0012200 4 0 0 |
                            78. | 001220007 0012200 5 0 0 |
                            79. | 001220008 0012200 1 0 0 |
                            80. | 001220008 0012200 2 0 0 |
                            |---------------------------------------------|
                            81. | 001220008 0012200 3 0 0 |
                            82. | 001220009 0012200 1 0 0 |
                            83. | 001220009 0012200 2 0 0 |
                            84. | 001220009 0012200 3 0 0 |
                            85. | 001220009 0012200 4 0 0 |
                            |---------------------------------------------|
                            86. | 001220010 0012200 1 0 0 |
                            87. | 001220010 0012200 2 0 0 |
                            88. | 001220010 0012200 3 0 0 |
                            89. | 001220010 0012200 4 0 0 |
                            90. | 001220010 0012200 5 0 0 |
                            |---------------------------------------------|
                            91. | 001220011 0012241 4 0 1 |
                            92. | 001220011 0012241 5 0 1 |
                            93. | 001220013 0012241 4 0 0 |
                            94. | 001220013 0012241 5 0 0 |
                            95. | 001220014 0012200 4 0 0 |
                            |---------------------------------------------|
                            96. | 001220014 0012200 5 0 0 |
                            97. | 001220015 0012200 4 0 0 |
                            98. | 001220015 0012200 5 0 0 |
                            99. | 001224104 0012241 4 0 0 |
                            100. | 001224104 0012241 5 0 0 |
                            |---------------------------------------------|
                            101. | 001224105 0012241 4 0 0 |
                            102. | 001224105 0012241 5 0 0 |
                            103. | 001224106 0012241 5 0 0 |
                            104. | 001240001 0012400 1 1 0 |
                            105. | 001240001 0012400 2 1 0 |
                            |---------------------------------------------|
                            106. | 001240001 0012400 5 1 0 |
                            107. | 001240002 0012400 1 0 1 |
                            108. | 001240002 0012400 2 0 1 |
                            109. | 001240002 0012400 5 0 1 |
                            110. | 001240003 0012400 1 0 0 |
                            |---------------------------------------------|
                            111. | 001240003 0012400 2 0 0 |
                            112. | 001240003 0012400 5 0 0 |
                            113. | 001240004 0012400 1 0 0 |
                            114. | 001240004 0012400 2 0 0 |
                            115. | 001240004 0012400 5 0 0 |
                            |---------------------------------------------|
                            116. | 001240005 0012400 1 0 0 |
                            117. | 001240005 0012400 2 0 0 |
                            118. | 001240005 0012451 5 0 1 |
                            119. | 001240006 0012400 1 0 0 |
                            120. | 001240006 0012400 2 0 0 |
                            |---------------------------------------------|
                            121. | 001240006 0012400 5 0 0 |
                            122. | 001240007 0012400 1 0 0 |
                            123. | 001240007 0012400 2 0 0 |
                            124. | 001240007 0012400 5 0 0 |
                            125. | 001240008 0012400 1 0 0 |
                            |---------------------------------------------|
                            126. | 001240008 0012400 2 0 0 |
                            127. | 001240008 0012400 5 0 0 |
                            128. | 001240009 0012400 1 0 0 |
                            129. | 001240009 0012400 2 0 0 |
                            130. | 001240009 0012452 5 0 1 |
                            |---------------------------------------------|
                            131. | 001240010 0012400 1 0 0 |
                            132. | 001240010 0012400 2 0 0 |
                            133. | 001240010 0012400 5 0 0 |
                            134. | 001240014 0012400 2 0 0 |
                            135. | 001240014 0012400 5 0 0 |
                            |---------------------------------------------|
                            136. | 001245101 0012451 5 1 0 |
                            137. | 001245103 0012451 5 0 0 |
                            138. | 001245104 0012451 5 0 0 |
                            139. | 001245105 0012451 5 0 0 |
                            140. | 001245106 0012451 5 0 0 |
                            |---------------------------------------------|
                            141. | 001245107 0012451 5 0 0 |
                            142. | 001245201 0012452 5 1 0 |
                            143. | 001245203 0012452 5 0 0 |
                            144. | 001250001 0012500 1 1 0 |
                            145. | 001250001 0012500 2 1 0 |
                            |---------------------------------------------|
                            146. | 001250001 0012500 3 1 0 |
                            147. | 001250002 0012500 1 0 1 |
                            148. | 001250002 0012500 2 0 1 |
                            149. | 001250002 0012500 3 0 1 |
                            150. | 001250003 0012500 1 0 0 |
                            |---------------------------------------------|
                            151. | 001250003 0012500 2 0 0 |
                            152. | 001250003 0012500 3 0 0 |
                            153. | 001250004 0012500 1 0 0 |
                            154. | 001250004 0012500 2 0 0 |
                            155. | 001250004 0012500 3 0 0 |
                            |---------------------------------------------|
                            156. | 001250005 0012500 1 0 0 |
                            157. | 001250005 0012500 2 0 0 |
                            158. | 001250005 0012500 3 0 0 |
                            159. | 001250006 0012500 1 0 0 |
                            160. | 001250006 0012500 2 0 0 |
                            |---------------------------------------------|
                            161. | 001250006 0012500 3 0 0 |
                            162. | 001250007 0012500 1 0 0 |
                            163. | 001250007 0012500 2 0 0 |
                            164. | 001250007 0012500 3 0 0 |
                            165. | 001290001 0012900 1 1 0 |
                            |---------------------------------------------|
                            166. | 001290001 0012900 2 1 0 |
                            167. | 001290001 0012900 3 1 0 |
                            168. | 001290001 0012900 4 1 0 |
                            169. | 001290002 0012900 1 0 1 |
                            170. | 001290002 0012900 2 0 1 |
                            |---------------------------------------------|
                            171. | 001290002 0012900 3 0 1 |
                            172. | 001290002 0012900 4 0 1 |
                            173. | 001290003 0012900 1 0 0 |
                            174. | 001290003 0012900 2 0 0 |
                            175. | 001290003 0012900 3 0 0 |
                            |---------------------------------------------|
                            176. | 001290003 0012900 4 0 0 |
                            177. | 001290003 0012951 5 0 1 |
                            178. | 001290004 0012900 1 0 0 |
                            179. | 001290004 0012900 2 0 0 |
                            180. | 001290004 0012900 3 0 0 |
                            |---------------------------------------------|
                            181. | 001290004 0012900 4 0 0 |
                            182. | 001290004 0012952 5 1 0 |
                            183. | 001290005 0012900 1 0 0 |
                            184. | 001290005 0012900 2 0 0 |
                            185. | 001290005 0012900 3 0 0 |
                            |---------------------------------------------|
                            186. | 001290005 0012900 4 0 0 |
                            187. | 001290005 0012953 5 1 0 |
                            188. | 001290006 0012900 1 0 0 |
                            189. | 001290006 0012900 2 0 0 |
                            190. | 001290006 0012900 3 0 0 |
                            |---------------------------------------------|
                            191. | 001290006 0012900 4 0 0 |
                            192. | 001290007 0012900 2 0 0 |
                            193. | 001290007 0012900 3 0 0 |
                            194. | 001290007 0012900 4 0 0 |
                            195. | 001290008 0012900 3 0 0 |
                            |---------------------------------------------|
                            196. | 001290008 0012900 4 0 0 |
                            197. | 001290010 0012900 4 0 0 |
                            198. | 001290011 0012900 4 0 0 |
                            199. | 001295101 0012951 5 1 0 |
                            200. | 001295103 0012951 5 0 0 |
                            |---------------------------------------------|
                            201. | 001295104 0012951 5 0 0 |
                            202. | 001295105 0012951 5 0 0 |
                            203. | 001295202 0012952 5 0 1 |
                            204. | 001295203 0012952 5 0 0 |
                            205. | 001295204 0012952 5 0 0 |
                            |---------------------------------------------|
                            206. | 001295205 0012952 5 0 0 |
                            207. | 001295206 0012952 5 0 0 |
                            208. | 001295304 0012953 5 0 1 |
                            209. | 001295305 0012953 5 0 0 |
                            210. | 002010001 0020100 1 1 0 |
                            |---------------------------------------------|
                            211. | 002010001 0020100 2 1 0 |
                            212. | 002010001 0020100 3 1 0 |
                            213. | 002010001 0020100 4 1 0 |
                            214. | 002010002 0020100 1 0 1 |
                            215. | 002010002 0020100 2 0 1 |
                            |---------------------------------------------|
                            216. | 002010002 0020100 3 0 1 |
                            217. | 002010002 0020100 4 0 1 |
                            218. | 002010003 0020100 1 0 0 |
                            219. | 002010003 0020100 2 0 0 |
                            220. | 002010003 0020100 3 0 0 |
                            |---------------------------------------------|
                            221. | 002010003 0020100 4 0 0 |
                            222. | 002010005 0020100 4 0 0 |
                            223. | 002010006 0020151 5 0 1 |
                            224. | 002015101 0020151 5 1 0 |
                            225. | 002015103 0020151 5 0 0 |
                            |---------------------------------------------|
                            226. | 002020001 0020200 1 1 0 |
                            227. | 002020001 0020200 2 1 0 |
                            228. | 002020002 0020200 1 0 1 |
                            229. | 002020002 0020200 2 0 1 |
                            230. | 002030001 0020300 1 1 0 |
                            |---------------------------------------------|
                            231. | 002030001 0020300 2 1 0 |
                            232. | 002030001 0020300 3 1 0 |
                            233. | 002030001 0020300 4 1 0 |
                            234. | 002030002 0020300 1 0 1 |
                            235. | 002030002 0020300 2 0 1 |
                            |---------------------------------------------|
                            236. | 002030002 0020300 3 0 1 |
                            237. | 002030002 0020300 4 0 1 |
                            238. | 002030003 0020300 1 0 0 |
                            239. | 002030003 0020300 2 0 0 |
                            240. | 002030003 0020300 3 0 0 |
                            |---------------------------------------------|
                            241. | 002030003 0020300 4 0 0 |
                            242. | 002040001 0020400 1 1 0 |
                            243. | 002040001 0020300 2 0 0 |
                            244. | 002040001 0020400 3 1 0 |
                            245. | 002040001 0020400 5 1 0 |
                            |---------------------------------------------|
                            246. | 002040002 0020400 1 0 1 |
                            247. | 002040002 0020400 3 0 1 |
                            248. | 002040002 0020400 5 0 1 |
                            249. | 002040003 0020400 1 0 0 |
                            250. | 002040003 0020441 4 0 1 |
                            |---------------------------------------------|
                            251. | 002040003 0020441 5 0 1 |
                            252. | 002040004 0020400 1 0 0 |
                            253. | 002040004 0020400 3 0 0 |
                            254. | 002040005 0020400 1 0 0 |
                            255. | 002040005 0020400 3 0 0 |
                            |---------------------------------------------|
                            256. | 002040005 0020400 5 0 0 |
                            257. | 002040006 0020400 3 0 0 |
                            258. | 002040007 0020400 3 0 0 |
                            259. | 002040007 0020400 5 0 0 |
                            260. | 002040008 0020400 5 0 0 |
                            |---------------------------------------------|
                            261. | 002040009 0020400 5 0 0 |
                            262. | 002040011 0020400 5 0 0 |
                            263. | 002044102 0020441 4 1 0 |
                            264. | 002044102 0020441 5 1 0 |
                            265. | 002044104 0020441 4 0 0 |
                            |---------------------------------------------|
                            266. | 002044104 0020441 5 0 0 |
                            267. | 002044105 0020441 4 0 0 |
                            268. | 002044105 0020441 5 0 0 |
                            269. | 002044106 0020441 5 0 0 |
                            270. | 002044201 0020442 4 1 0 |
                            |---------------------------------------------|
                            271. | 002044201 0020442 5 1 0 |
                            272. | 002044202 0020442 4 0 1 |
                            273. | 002044202 0020442 5 0 1 |
                            274. | 002044204 0020442 5 0 0 |
                            275. | 002044205 0020442 5 0 0 |
                            |---------------------------------------------|
                            276. | 002050001 0020500 1 1 0 |
                            277. | 002050001 0020500 2 1 0 |
                            278. | 002050002 0020500 1 0 1 |
                            279. | 002050002 0020500 2 0 1 |
                            280. | 002050003 0020500 1 0 0 |
                            |---------------------------------------------|
                            281. | 002050003 0020500 2 0 0 |
                            282. | 002050004 0020500 1 0 0 |
                            283. | 002050004 0020500 2 0 0 |
                            284. | 002050005 0020500 1 0 0 |
                            285. | 002050005 0020500 2 0 0 |
                            |---------------------------------------------|
                            286. | 002050006 0020500 2 0 0 |
                            287. | 002060004 0020651 5 0 1 |
                            288. | 002065101 0020651 5 1 0 |
                            289. | 002065103 0020651 5 0 0 |
                            290. | 002065104 0020651 5 0 0 |
                            |---------------------------------------------|
                            291. | 002065105 0020651 5 0 0 |
                            292. | 002065106 0020651 5 0 0 |
                            293. | 002065107 0020651 5 0 0 |
                            294. | 002065108 0020651 5 0 0 |
                            295. | 002090001 0020900 1 1 0 |
                            |---------------------------------------------|
                            296. | 002090001 0020900 2 1 0 |
                            297. | 002090001 0020900 3 1 0 |
                            298. | 002090001 0020900 4 1 0 |
                            299. | 002090002 0020900 1 0 1 |
                            300. | 002090002 0020900 2 0 1 |
                            |---------------------------------------------|
                            301. | 002090002 0020900 3 0 1 |
                            302. | 002090002 0020900 4 0 1 |
                            303. | 002090003 0020900 1 0 0 |
                            304. | 002090003 0020900 2 0 0 |
                            305. | 002090003 0020931 3 0 1 |
                            |---------------------------------------------|
                            306. | 002090003 0020900 4 0 0 |
                            307. | 002090004 0020900 1 0 0 |
                            308. | 002090004 0020900 2 0 0 |
                            309. | 002090004 0020900 3 0 0 |
                            310. | 002090004 0020900 4 0 0 |
                            |---------------------------------------------|
                            311. | 002090006 0020932 3 1 0 |
                            312. | 002090007 0020933 3 0 1 |
                            313. | 002090008 0020900 4 0 0 |
                            314. | 002093102 0020931 3 1 0 |
                            315. | 002093202 0020932 3 0 1 |
                            |---------------------------------------------|
                            316. | 002093301 0020933 3 1 0 |
                            317. | 002100001 0021000 1 1 0 |
                            318. | 002100001 0021000 2 1 0 |
                            319. | 002100001 0021000 3 1 0 |
                            320. | 002100002 0021000 1 0 1 |
                            |---------------------------------------------|
                            321. | 002100002 0021000 2 0 1 |
                            322. | 002100002 0021000 3 0 1 |
                            323. | 002100003 0021000 1 0 0 |
                            324. | 002100003 0021000 2 0 0 |
                            325. | 002100003 0021000 3 0 0 |
                            |---------------------------------------------|
                            326. | 002100004 0021000 2 0 0 |
                            327. | 002100004 0021000 3 0 0 |
                            328. | 002110001 0021100 1 1 0 |
                            329. | 002110001 0021100 2 1 0 |
                            330. | 002110001 0021100 3 1 0 |
                            |---------------------------------------------|
                            331. | 002110001 0021100 4 1 0 |
                            332. | 002110002 0021100 1 0 1 |
                            333. | 002110002 0021100 2 0 1 |
                            334. | 002110002 0021100 3 0 1 |
                            335. | 002110002 0021100 4 0 1 |
                            |---------------------------------------------|
                            336. | 002110003 0021100 1 0 0 |
                            337. | 002110003 0021100 2 0 0 |
                            338. | 002110003 0021100 3 0 0 |
                            339. | 002110003 0021100 4 0 0 |
                            340. | 002110004 0021100 1 0 0 |
                            |---------------------------------------------|
                            341. | 002110004 0021100 2 0 0 |
                            342. | 002110004 0021100 3 0 0 |
                            343. | 002110005 0021100 1 0 0 |
                            344. | 002110005 0021100 2 0 0 |
                            345. | 002110005 0021100 3 0 0 |
                            |---------------------------------------------|
                            346. | 002110005 0021100 4 0 0 |
                            347. | 002110006 0021100 2 0 0 |
                            348. | 002110006 0021100 3 0 0 |
                            +---------------------------------------------+


                            Thank you in advance,

                            Enrique

                            Comment


                            • #15
                              The dataset refers to a household survey where members are interviewed based on the relationship to the head of the household, in a context where husbands may have more than one wife. If a household head changes spouses, then that person is interviewed in the following wave and shows up with a new pidlink. If a daughter interviewed in a given wave gets married, becomes a wife and moves out of the household, she is re-interviewed keeping the same pidlink but a new hhid.
                              If husbands may have more than one wife, why are you surprised that there are more distinct wives than husbands? I think your code checks whether a HH ever has more than one husband/wife per wave, not whether there are multiple husbands or wives per HH ID over all the waves in which that HH ID appears.
                              Devra Golbe
                              Professor Emerita, Dept. of Economics
                              Hunter College, CUNY

                              Comment

                              Working...
                              X