Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to compare the values of variables for respondent and his spouse within the same household?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: How to compare the values of variables for respondent and his spouse within the same household?
Date   Sat, 23 Jun 2012 17:56:09 +0100

Couples are definable this way (I assume numeric ID variables; code
needs tweaking otherwise):

gen minID = min(personID, spouseID)
gen maxID = max(personID, spouseID)

bysort minID maxID : gen n = _N
list *ID if n != 2

gen different = .

foreach v of varlist v1 v2 {
       bysort minID maxID: replace different =  `v'[1] != `v'[2]
       list *ID `v' if different & n == 2
}

All follows from accessible stuff:

SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q4/08   SJ 8(4):588--591                                 (no commands)
        tip on how to handle dyadic identifiers

How do I list observations in a group that differ on a variable?
http://www.stata.com/support/faqs/data/diff.html

The Statalist FAQ reminds you to -search- Stata FAQs before posting.

Nick

On Sat, Jun 23, 2012 at 5:10 PM, xueliansharon <[email protected]> wrote:

> I have a data set which has records for both the family respondent and
> his/her spouse. And I want to check whether the values of each variable for
> the family respondent and his spouse are the same, e.g., in the following
> data file, I want to check whether the values of the variable v1 are the
> same for person 1010 (FamR) and 1020 (Spouse), person 2020 (FamR) and 2010
> (spouse), etc. How to realize this purpose?
>
> The data structure is like:
>
> FamR  person ID   spouse ID    v1    v2
> 1        1010          1020
> 0        1020          1010
> 1        2020          2010
> 0        2010          2020
> 1        3012          3001
> 0        3001          3012
> 1        4011          0
>
> Here, FamR is a dummy indicating whether the respondent is a Family
> Respondent (=1, is Family Respondent, =0, Spouse of FamR). "PersonID"
> provides the ID for the individual, and "SpouseID" provides the ID for the
> individual's spouse. When SpouseID=0, it means that the individual doesn't
> have a spouse. v1 and v2 are two variables.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index