Announcement

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

  • Creating sibling-pairs using unique id

    Hi:

    I have a dataset that contains the following variables: unique household id (hhold), unique household member id (id) within each household, a variable that defines relationship with head of the household (relationship). I want to create a dataset where each row represents a unique sibling pair within the household. Specifically, individuals with the relationship values 1 and 7 would form one type of sibling pair, 2 and 10 would form another, individuals with values 3 would be siblings as well, so would individuals with values 5 and 5, 8 and 8. How would I go about doing this?

  • #2
    A data example would help (FAQ Advice #12).

    This may help. Code not tested at all.

    Code:
    gen work = inlist(relationship, 1. 7) 
    bysort hhold (work) : gen pair1_7 = work == work[_N] & work == 1 & work[_N-1] == 1 
    by hhold : gen other1_7 = cond(_n == _N & pair1_7, id[_N-1], cond(_n == _N - 1 & pair1_7, id[_N], .)) 
    
    replace work = inlist(relationship, 2, 10)
    bysort hhold (work) : gen pair2_10 = work == work[_N] & work == 1 & work[_N-1] == 1 
    * compare previous case 
    
    replace work = relationship == 3 
    * and so on
    What should happen if e.g. 3 people satisfy any such criterion?

    See also https://journals.sagepub.com/doi/pdf...867X0800800414

    Comment


    • #3
      https://www.statalist.org/forums/for...ng-identifiers appears related.

      Please don't run such closely related threads at the same time -- or at least give cross-references.

      Comment


      • #4
        Thanks, Nick! Sorry for the double-post.

        Comment

        Working...
        X