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

From |
Michael Norman Mitchell <Michael.Norman.Mitchell@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: reshape question |

Date |
Mon, 01 Feb 2010 15:22:24 -0800 |

Dear Alan

clear input dyad hr1 hr2 sr1 sr2 gr1 gr2 1 1.2 .6 6 7 1 1 2 4.3 2.3 5 9 -1 -1 3 .4 .6 3 4 1 1 4 .3 .5 6 8 1 1 5 3.2 1 2 6 -1 -1 6 1.1 .8 3 8 1 1 7 2 1.5 5 7 1 1 8 .4 1.6 7 4 -1 -1 9 .3 .5 3 3 1 1 10 3.2 2 5 8 1 1 11 .8 2.1 8 5 -1 -1 12 2.3 2.5 5 7 -1 -1 13 1 2 4 6 1 1 14 2.5 1.5 6 7 1 1 15 2 .5 5 6 1 1 16 1.8 2.6 7 4 -1 -1 17 4.3 2 2 4 -1 -1 18 1 2 4 4 -1 -1 19 2.5 2.5 6 5 -1 -1 20 1 .5 3 4 -1 -1 end /* dyad person gr sr hr1 hr2 1 1 1 6 1.2 .6 1 2 1 7 .6 1.2 2 1 -1 5 4.3 2.3 2 2 -1 9 2.3 4.3 */ reshape long hr sr gr, i(dyad) j(person) save t1, replace * get hr1 info use t1, clear keep dyad person hr rename hr hr1 save t2, replace * get hr2 info, by transposing row 1 and 2 use t1, clear keep dyad person hr replace person = 3 - person rename hr hr2 save t3, replace * merge them together use t1 merge 1:1 dyad person using t2, gen(m1) merge 1:1 dyad person using t3, gen(m2) I hope that helps! Best regards, Michael N. Mitchell See the Stata tidbit of the week at... http://www.MichaelNormanMitchell.com Visit me on Facebook at... http://www.facebook.com/MichaelNormanMitchell Alan Acock wrote:

Kenney, Kashy, & Cook. Dyadic Data Analysis Has a wide dataset thatlooks like this:dyad hr1 hr2 sr1 sr2 gr1 gr2 1 1.2 .6 6 7 1 1 2 4.3 2.3 5 9 -1 -1 3 .4 .6 3 4 1 1 4 .3 .5 6 8 1 1 5 3.2 1 2 6 -1 -1 6 1.1 .8 3 8 1 1 7 2 1.5 5 7 1 1 8 .4 1.6 7 4 -1 -1 9 .3 .5 3 3 1 1 10 3.2 2 5 8 1 1 11 .8 2.1 8 5 -1 -1 12 2.3 2.5 5 7 -1 -1 13 1 2 4 6 1 1 14 2.5 1.5 6 7 1 1 15 2 .5 5 6 1 1 16 1.8 2.6 7 4 -1 -1 17 4.3 2 2 4 -1 -1 18 1 2 4 4 -1 -1 19 2.5 2.5 6 5 -1 -1 20 1 .5 3 4 -1 -1Where the dyads are interchangeable (same sex roomates). hr1 is timeroommate arbitrarily labeled 1 works on housekeeping, hr2 is same forroommate labeled 2, sr1 is roommate's 1' satisfaction, sr2 is thepartner's satisfaction, gr1 and gr2 are their genders. He wants it ina sort of long format,dyad person gr sr hr1 hr2 1 1 1 6 1.2 .6 1 2 1 7 .6 1.2 2 1 -1 5 4.3 2.3 2 2 -1 9 2.3 4.3Dyad, person, and gr and sr are in long format, but hr1 and hr2 arenot. Also, in row 1 we have hr1 then hr2 as in the wide dataset, butin row two we have hr2 for the first person in the hr1 column and hr1for the first person in the hr2 column.He then runs a SAS command proc mixed covtest; class dyadid; model sr = hr1 hr2 / solution ddfm=satterth; repeated / type = cs subject = dyadid; I can run reshape long sr gr, i(dyad) j(person)but this doesn't do the hr1 the way they need them. The results showhow much a person's time (actor) doing chores influences their ownsatisfaction and how much a partner's time doing chores influences theactor's satisfaction.How can I reshape the data to duplicate their result. Alan Acock * * 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/

* * 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/

**Follow-Ups**:**Re: st: reshape question***From:*Alan Acock <acock@mac.com>

**References**:**st: reshape question***From:*Alan Acock <acock@mac.com>

- Prev by Date:
**Re: st: Multiplying coefficients and standard errors in -estout-** - Next by Date:
**re: st: Roy Wada** - Previous by thread:
**st: reshape question** - Next by thread:
**Re: st: reshape question** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |