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

From |
Jeph Herrin <junk@spandrel.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: Fw: RE: st: RE: Data aligning |

Date |
Thu, 19 Mar 2009 08:18:58 -0400 |

Are there two variables named -Reporter-, and two named -Partner-? This is why it is confusing. Let's assume you really have something like: rep1 part1 year1 var1 rep2 part2 year2 var2 Then you should separate in to 2 files and merge the second one to the first. Something like: preserve keep rep2 part2 year2 var2 ren rep2 rep1 ren part2 part1 ren year2 year1 sort rep1 part1 year1 save temp, replace restore drop rep2 part2 year2 var2 sort rep1 part1 year1 merge rep1 part1 year1 using temp, keeping(var2) hope this helps, Jeph Anita Sayal wrote:

I think you are right..I didnt explain it well.This is purly a data arranging issue, pre-estimation. The second set of Reporter Partner Year to be dropped once Var2 data is aligned with corresponding the Year Report Partener (frist 3 columns)..for example A D 1986 .4 should be aligned with 2nd row 2..and C A 1989 .3 should be in row 6..its a question of how to do this for a large dataset..Reporter Partner Year Var1 Reporter Partner Year Var2A B 1985 10 A D 1986 .4 A C 1986 12 C A 1989 .3 A D 1986 14 B A 1985 15 B C 1985 18C A 1989 20--- On Wed, 3/18/09, Nick Cox <n.j.cox@durham.ac.uk> wrote:From: Nick Cox <n.j.cox@durham.ac.uk> Subject: RE: st: RE: Data aligning To: statalist@hsphsun2.harvard.edu Date: Wednesday, March 18, 2009, 3:05 PM Tell people more about your precise data structure andvariable names.(You can not have two variables with the same name.)I think your previous description led Joseph (and nodoubtseveral others) to guess that you were talking about twodifferentdatasets.Nickn.j.cox@durham.ac.ukAnita Sayal I repeated your example..Its works fine doingmanually..buthow would I replicate for a very large data set and when all datais insingle file --- On Wed, 3/18/09, Joseph Coveney <jcoveney@bigplanet.com> wrote:Would someone Please tell me what commands artoaeused toalign the data for Var2 with corresponding Reporter PartnercombinationinColumn 1 and 2 for corresponding years.. trying to do thiis for alargedataset..TX Reporter Partner Year Var1 ReporterPartner Year Var2A B 1985 10 A D 1986.4A C 1986 12 C A 1989 .3 A D 1986 14 B A 1985 15 B C 1985 18 C A 1989 20---------------------------------------------------------------------------------merge- is what I think you're looking for.Trythedo-file below, and see whether it gives you the kind of data alignmentthatyouwant. Joseph Coveney clear * set more off input str1 Reporter str1 Partner int Year byteVar1"A" "B" 1985 10 "A" "C" 1986 12 "A" "D" 1986 14 "B" "A" 1985 15 "B" "C" 1985 18 "C" "A" 1989 20 end tempfile tmpfil0 save `tmpfil0' clear input str1 Reporter str1 Partner int Year floatVar2"A" "D" 1986 .4 "C" "A" 1989 .3 end merge Reporter Partner Year using `tmpfil0',sortlist Reporter Partner Year Var1 Var2, noobssepby(_merge)exit* * 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/

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

**References**:**Fw: RE: st: RE: Data aligning***From:*Anita Sayal <anitasayal@yahoo.com>

- Prev by Date:
**st: Fixed effects and clustering** - Next by Date:
**Re: st: fully modified OLS and dynamic OLS** - Previous by thread:
**Fw: RE: st: RE: Data aligning** - Index(es):

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