Announcement

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

  • Checking missing spouse in a data set

    Hello everyone.
    Can someone help me. I want to list all IDs which reported that the head was married but in the list of household members there is no spouse. So I only want the IDs of the households whose household head's marital status is married but has no spouse as part of the household members list
    householdID Marital status relation_to_head
    1 2 1
    1 2 2
    1 1 3
    1 1 3
    2 2 1
    2 1 3
    2 1 4
    2 1 3
    2 1 3
    3 0 1
    3 1 2
    4 3 1
    4 1 3
    4 1 3
    5 2 1
    5 2 2
    5 1 3
    5 1 4
    5 1 4
    5 1 4
    Marital status
    1= Never married
    2= Married
    3= Divorced/ separated

    Relationship to head
    1= Head
    2= Spouse
    3= Son/daughter
    4= Other relatives

  • #2
    Some technique at https://www.stata.com/support/faqs/d...ble-recording/ may help here. This is in the same spirit.

    Code:
    egen count1 = total(status == 2 & relation == 1), by(household_id)
    
    egen count2 = total(status == 2 & relation == 2), by(household_id)  
    
    egen tag = tag(household_id) 
    
    list household_id if tag & count1 & !count2
    where

    count1 could also be expressed as count1 > 0

    !count2 could also be expressed as count2 == 0

    Comment


    • #3
      This has worked perfectly. Thank you so much Nick. I appreciate your assistance.
      Last edited by Lemekezani Chilora; 14 Jun 2023, 07:44.

      Comment

      Working...
      X