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

Re: st: reshaping data


From   Russell Dimond <[email protected]>
To   [email protected]
Subject   Re: st: reshaping data
Date   Fri, 24 Jun 2005 14:47:49 -0500

Hi Mazhar,

The only thing you're missing is a "j" variable to tell Stata which observation is which within each x group.

bysort x: gen j=_n
reshape y z, i(x) j(j)

Russell Dimond
Research Computing Specialist
Social Science Computing Cooperative
University of Wisconsin-Madison

Mazhar Islam wrote:

I have a dataset with the following format:

X Y Z
1 12 2.5 1 3 3.4
1 7 8.9
2 18 0.9
2 6 1.9
2 11 3.7
3 5 1.2
3 19 4.5
3 8 5.6

I want to reshape it as follows:

X Y1 Z1 Y2 Z2 Y3 Z3 1 12 2.5 3 3.4 7 8.9
2 18 0.9 6 1.9 11 3.7
3 5 1.2 19 4.5 8 5.6

I know I need to use reshape command. But don't know
how. Can anyone please help? Thanks a lot.
Mazhar








+-------------------------+
| gstn comp distance |
|-------------------------|
1. | 4 105 7174.6529 |
2. | 4 52 9432.1751 |
3. | 4 55 9760.1456 |
4. | 4 59 10351.248 |
5. | 4 57 10590.998 |
|-------------------------|
6. | 5 691 8421.3531 |
7. | 5 111 8912.8855 |
8. | 5 109 9413.6016 |
9. | 5 7 10006.499 |
10. | 5 110 10485.966 |
|-------------------------|
11. | 7 10 5240.1692 |
12. | 7 9 7148.0657 |
13. | 7 501 8312.9357 |
14. | 7 8 8761.7633 |
15. | 7 494 11348.099 |




____________________________________________________ Yahoo! Sports Rekindle the Rivalries. Sign up for Fantasy Football http://football.fantasysports.yahoo.com
*
* 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