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

Re: st: Transpose?


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: Transpose?
Date   Tue, 13 Apr 2004 17:45:13 -0400

At 04:05 PM 4/13/2004 -0500, Justin ([email protected]) wrote:
I have data that looks like this:

yr          series           country1       country2      country3
1960      exports           (value)        (value)         (value)
1960      imports           (value)         (value)         (value)
1961      exports            "     "           " "               "    "
1961

etc...

I would like to get the data so it looks like:

yr     country   series(exports)    series(imports)
1960   1             (value)            (value)
1961   1              ""                      ""
1960   2             ""                        ""
1961  2                ""                      ""


I am new to Stata and completely at a loss as to how to accomplish this.  Any
help would be greatly appreciated.
7
Thanks,
Justin
This is not a case for transpose or -xpose-.

It looks as if you need to do two -reshape- steps.

-reshape- this to long form with only one content variable: what you show as value. Thus, you would end up with data looking something like this:

yr country series value
1960 1 imports (value)
1960 1 exports (value)
1960 2 imports (value)
1960 2 exports (value)
1960 3 imports (value)
1960 3 exports (value)

Then -reshape- it a second time to wide form, splitting the imports from the exports.

This is a sketchy description. You need to fill in the details, which depend on your particular variable names and types. It may help to have series as numerically coded. See -help reshape-.

Good luck.
-- David


David Kantor
Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404

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