Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: stacking horizontal data


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: stacking horizontal data
Date   Sat, 27 Oct 2007 18:47:03 +0100 (BST)

--- John Bunge <[email protected]> wrote:
> I have a dataset that can be stylized as follows:
> 
> 
>              2000 2001 2002
> c1 c2     10     6       44    
> c1 c3     2       3       9     
> c2 c3     88     7       100    
> 
> It displays bilateral trade data with the exporting country in the
> first and the importing country in the second column.
> 
> To create a dataset for panel estimations, I need to change it into
> the following arrangement:
> 
> c1 c2  2000   10
> c1 c2  2001    6
> c1 c2  2002   44
> c1 c3  2000    2
> c1 c3  2001    3
> c1 c3  2002    9
> c2 c3  2000   88
> c2 c3  2001    7
> c2 c3  2002  100

This is a job for -reshape-, see: -help reshape- and example below:

*-------------------- begin example ----------------
clear
input str2 exp str2 imp  vol2000 vol2001 vol2002
c1 c2     10     6       44    
c1 c3     2       3       9     
c2 c3     88     7       100 
end
gen id = exp + imp
reshape long vol, i(id) j(year)
*------------------ end example ---------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten



-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good  http://uk.promotions.yahoo.com/forgood/environment.html
*
*   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