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]

st: RE: need reshape help


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: need reshape help
Date   Tue, 8 Jun 2010 14:14:41 +0100

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/


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