Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: need reshape help


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 

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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index