Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Expanding dataset


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   Re: st: Expanding dataset
Date   Mon, 16 Feb 2004 16:45:16 -0000

Dev and Stephen,

Thanks for your answer. However notice that to create a dataset like the one
described in my previous email I would have to include country1, country2
and year in "varlist" while using the -joinby- command; the disadvantage
will be that no information about x's will be shown in the expanded dataset
when the observation is only present in the "using data" (which is 50% of
the data)

In this case is better to rename country1 as country2 and vice versa, save
as a new dataset and then:

merge country1 country2 year using "modified dataset"

The new dataset will have double number of observations, exactly the number
of country1-country2 combinations that were missing in the original dataset.

Thanks,

Rafa

______________________________
R.E. De Hoyos
Department of Applied Economics
University of Cambridge
Cambridge, CB3 9DE, UK
Tel: +44 1223 335269



----- Original Message -----
From: "Dev Vencappa" <[email protected]>
To: <[email protected]>
Sent: Saturday, February 14, 2004 9:28 PM
Subject: Re: st: Expanding dataset


> >>> [email protected] 02/14/04 09:08pm >>>
> On Sat, 14 Feb 2004, R.E. De Hoyos wrote:
>
> >
> > I have a dataset with bilateral trade data as follows:
> >
> > Country1  Country2     year         btrade
> > US            Arg            1950         x1
> > US            Arg            1951         x2
> > US            Bra            1949         x3
> > US            Can            1949        x4
> > US            Can            1950        x5
> > US            Can            1951        x6
> > US            Col             1950        x7
> > US            Chile           1950        x9
> > US            Mex            1950        x10
> > Arg            Bra             1950        x11
> > Arg            Can            1951        x12
> >
> Stephen replied to this. Let me expand on it a bit. Basically what Stephen
is suggesting is to have the same dataset stored in a second file. This
second data set will however have country 2 renamed to country 1 and vice
versa. Then a joinby command on the two datasets should do the job. The
joinby variables would be country 1 and year. If you want to be sure whether
joinby is doing it right, you might want to add the unm(both) option in the
joinby command, just to see if this is you are getting what you want. I
think this is correct.
>
> Dev
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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