Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: -reshape- question [was: Re: st: Thread-Index: <random garbage>] |

Date |
Fri, 23 Aug 2013 16:30:28 +0100 |

You have probably read irritating interviews in which some rich person smirks and says, "Well, the first million dollars was the hardest." (Probably billion these days.) It won't get in any dictionary of quotations, but the first 10 -reshape-s are the hardest. Then it just clicks. Meanwhile, my own small struggles are documented at http://www.stata.com/support/faqs/data-management/problems-with-reshape/ Nick njcoxstata@gmail.com On 23 August 2013 16:11, Nickolas Lyell <nlyell@naco.org> wrote: > Thanks, I got it to work in a slightly less elegant manner. (using javascript to write all my rename commands) I'll go back and clean up the code in this manner though. > > Cheers, > -- > Nicholas Lyell > Research Associate > National Association of Counties | NACo > nlyell@naco.org | 202.661.8820 > > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox > Sent: Friday, August 23, 2013 11:00 AM > To: statalist@hsphsun2.harvard.edu > Subject: Re: -reshape- question [was: Re: st: Thread-Index: <random garbage>] > > . input County description v1990 v1991 v1992 > > County descrip~n v1990 v1991 v1992 > 1. 1 611 512.2 436.7 347.9 > 2. 1 612 63.4 67.8 83.4 > 3. end > > . reshape long v, i(C d) j(year) > (note: j = 1990 1991 1992) > > Data wide -> long > ----------------------------------------------------------------------------- > Number of obs. 2 -> 6 > Number of variables 5 -> 4 > j variable (3 values) -> year > xij variables: > v1990 v1991 v1992 -> v > ----------------------------------------------------------------------------- > > . reshape wide v, i(County year) j(desc) > (note: j = 611 612) > > Data long -> wide > ----------------------------------------------------------------------------- > Number of obs. 6 -> 3 > Number of variables 4 -> 4 > j variable (2 values) description -> (dropped) > xij variables: > v -> v611 v612 > ----------------------------------------------------------------------------- > > . l > > +------------------------------+ > | County year v611 v612 | > |------------------------------| > 1. | 1 1990 512.2 63.4 | > 2. | 1 1991 436.7 67.8 | > 3. | 1 1992 347.9 83.4 | > +------------------------------+ > > > Nick > njcoxstata@gmail.com > > > On 23 August 2013 15:50, Nickolas Lyell <nlyell@naco.org> wrote: >> Haha, Thanks Nick. >> >> Maybe always the best answer. Just being a bit lazy I suppose. (there is a lot of renaming for 3-digit NAICS codes) >> >> -- >> Nick >> >> -----Original Message----- >> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >> Sent: Friday, August 23, 2013 10:40 AM >> To: statalist@hsphsun2.harvard.edu >> Subject: Re: -reshape- question [was: Re: st: Thread-Index: <random garbage>] >> >> Here the best way to learn it is probably to try what you want -- and come back to us if you don't understand the results. >> >> I know that could be an answer to almost any question, but I give it nevertheless. >> Nick >> njcoxstata@gmail.com >> >> >> On 23 August 2013 15:25, Nickolas Lyell <nlyell@naco.org> wrote: >>> Ok. So when I am attempting to reshape long in time (after the very wide transformation), I will Most likely want to rename my variables to reshape long in time, correct? (from dec1990211) with "1990" being the year part and "211" being the NAICS code. >>> >>> As long as I rename them "NAICS2111990", Stata will understand which part identifies the year? Or will I have to indicate that in the reshape command? >>> >>> >>> Nicholas Lyell >>> Research Associate >>> National Association of Counties | NACo nlyell@naco.org | 202.661.8820 >>> >>> >>> -----Original Message----- >>> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >>> Sent: Friday, August 23, 2013 10:11 AM >>> To: statalist@hsphsun2.harvard.edu >>> Subject: -reshape- question [was: Re: st: Thread-Index: <random garbage>] >>> >>> Numeric digits 0...9 are fine in variable names so long as they are not offered as first character. Just specify a stub you like in -j()-. >>> >>> Nick >>> njcoxstata@gmail.com >>> >>> >>> On 23 August 2013 14:54, Nickolas Lyell <nlyell@naco.org> wrote: >>>> I seem to remember a warning against using numbers for variable names in the reshape command, but I wanted to make sure. >>>> >>>> I have a list of county GDP by industry with Industry by county long and GDP by year wide. I would like to invert this so that I have years by county long and GDP by industry wide. I know that I cannot use variable names that are more than one word long when transforming to wide, so I would like to turn the “description” variable into it’s industry NAICS code. IE: “GDP: Educational Services” → 611 . >>>> >>>> My data is formatted like this: >>>> >>>> County description 1990 1991 1992 … >>>> 1 611 512.2 436.7 347.9 … >>>> 1 612 63.4 67.8 83.4 … >>>> >>>> >>>> Can I use the 3-digit NAICS codes to reshape my data into wide with numbers as NAICS (year-NIACS) so that I can then reshape it long (so it can be a time series)? >>>> >>>> >>>> Nicholas Lyell >>>> Research Associate >>>> National Association of Counties | NACo nlyell@naco.org | 202.661.8820 >>>> >>>> >>>> * >>>> * For searches and help try: >>>> * http://www.stata.com/help.cgi?search >>>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**-reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nick Cox <njcoxstata@gmail.com>

**RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nickolas Lyell <nlyell@naco.org>

**Re: -reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nick Cox <njcoxstata@gmail.com>

**RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nickolas Lyell <nlyell@naco.org>

**Re: -reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nick Cox <njcoxstata@gmail.com>

**RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]***From:*Nickolas Lyell <nlyell@naco.org>

- Prev by Date:
**Re: st: Mvdecode Problem** - Next by Date:
**st: ttest** - Previous by thread:
**RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]** - Next by thread:
**st: Mvdecode Problem** - Index(es):