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]
RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]
From
Nickolas Lyell <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: -reshape- question [was: Re: st: Thread-Index: <random garbage>]
Date
Fri, 23 Aug 2013 11:11:43 -0400
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
[email protected] | 202.661.8820
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Friday, August 23, 2013 11:00 AM
To: [email protected]
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
[email protected]
On 23 August 2013 15:50, Nickolas Lyell <[email protected]> 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: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Friday, August 23, 2013 10:40 AM
> To: [email protected]
> 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
> [email protected]
>
>
> On 23 August 2013 15:25, Nickolas Lyell <[email protected]> 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 [email protected] | 202.661.8820
>>
>>
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
>> Sent: Friday, August 23, 2013 10:11 AM
>> To: [email protected]
>> 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
>> [email protected]
>>
>>
>> On 23 August 2013 14:54, Nickolas Lyell <[email protected]> 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 [email protected] | 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/