Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Scott Merryman <scott.merryman@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Reshaping but not numeric and more a loop needed! |

Date |
Sat, 29 Oct 2011 19:14:33 -0500 |

Something like this? clear input A B 1.11 1.11 1.11 1.12 1.11 1.13 1.11 1.14 1.11 1.15 1.11 1.16 1.11 1.19 1.11 1.26 1.11 1.28 1.11 1.29 1.11 1.63 1.11 1.64 1.20 1.11 1.20 1.12 1.20 1.20 1.20 1.20 1.21 1.13 1.21 1.14 1.21 1.21 1.21 1.22 1.21 1.23 end bys A: gen tag = _n egen tag2 = group(A) reshape wide A B, j(tag) i(tag2) rename A1 A drop A? A?? tag2 l Scott On Sat, Oct 29, 2011 at 6:29 PM, Miyu Lee <miyu.lee1@googlemail.com> wrote: > Hello > > I want to reshape the following table > > A B > 1.11 1.11 > 1.11 1.12 > 1.11 1.13 > 1.11 1.14 > 1.11 1.15 > 1.11 1.16 > 1.11 1.19 > 1.11 1.26 > 1.11 1.28 > 1.11 1.29 > 1.11 1.63 > 1.11 1.64 > 1.20 1.11 > 1.20 1.12 > 1.20 1.20 > 1.20 1.20 > 1.21 1.13 > 1.21 1.14 > 1.21 1.21 > 1.21 1.22 > 1.21 1.23 > etc etc > > to look like this: > > A B1 B2 B3 > 1.11 1.11 1.12 1.13 etc > 1.20 1.11 1.12 1.20 etc > 1.21 1.14 etc. > > !!! my ideal would be if STATA just puts the B value next to the B > value of the first observation within each group, as long as the A > values are the same.!!! > > reshape does not work here because it creates a huge matrix where all > identical B values are stacked on top of each other and/or there might > also be a problem that the size of the group is not equal. > > any suggestions would be helpful. the matrix is very long so a loop or > anything similar seems the only alternative. > > Many thanks > > Miyu > * > * 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/

**Follow-Ups**:**RE: st: Reshaping but not numeric and more a loop needed!***From:*Nick Cox <n.j.cox@durham.ac.uk>

**References**:**st: Reshaping but not numeric and more a loop needed!***From:*Miyu Lee <miyu.lee1@googlemail.com>

- Prev by Date:
**st: Reshaping but not numeric and more a loop needed!** - Next by Date:
**st: Data entry into TeX files (other than tables and graphs)** - Previous by thread:
**st: Reshaping but not numeric and more a loop needed!** - Next by thread:
**RE: st: Reshaping but not numeric and more a loop needed!** - Index(es):