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]
st: RE: RE: need reshape help
From 
 
"Nick Cox" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: RE: RE: need reshape help 
Date 
 
Tue, 8 Jun 2010 14:42:22 +0100 
I've not thought of how smart this is for 3 or more siblings. But I have previously discussed trickery that could help under this heading: 
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
Nick 
[email protected] 
Nick Cox
bysort famid aid : gen j = _n
reshape wide pair, i(famid aid) j(j)
Nick 
[email protected] 
Averett, Susan L
I have a data set that I need to reshape. I have two id codes that TOGETHER uniquely identify each individual in my survey.
FAMID is a number and AID is a strong. I have a variable pair, that identifies what type of sibling they are. Respondents can be in more than one pair if three or more siblings from the same family were interviewed.   The data are currently in this form:
FAMID                PAIR                AID
123                TWMM123        10
123                TWMM123        20
123                FSMF001        30
123                FSMF001        10
123                FSMF002        30
123                FSMF002        20
I need the specific pair designations for each respondent, so I need to reshape the to create several PAIR variables so the file looks like this:
FAMID                PAIR1        AID        PAIR2
123                TWMM123        10        FSMF001
123                TWMM123        20        FSMF002
123                FSMF001        30        FSMF002
BUT, I can't figure out how to do it using reshape. Any help would be appreciated.
*
*   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/