Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: reshape data


From   Tyler Frazier <tyfrazier@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: reshape data
Date   Sat, 24 Jul 2010 17:25:47 -0400

got it! thanks Phil!

On Sat, Jul 24, 2010 at 2:29 PM, Phil Schumm <pschumm@uchicago.edu> wrote:
> On Jul 24, 2010, at 1:02 PM, Tyler Frazier wrote:
>>
>> I am trying to reshape a set of data such that
>>
>> bldg_id       No_jobs       zone_id        bldg_type
>> 1                    3                  2                 1
>> 2                    4                  2                 1
>> 3                    2                  1                 2
>> 4                    2                  2                 3
>>
>>
>> becomes
>>
>>
>> job_id             bldg_id           zone_id        bldg_type
>> 1                         1                   2                   1
>> 2                         1                   2                   1
>> 3                         1                   2                   1
>> 4                         2                   2                   1
>> 5                         2                   2                   1
>> 6                         2                   2                   1
>> 7                         2                   2                   1
>> 8                         3                   1                   2
>> 9                         3                   1                   2
>> 10                       4                   2                   3
>> 11                       4                   2                   3
>>
>> in spss this was fairly simple, but I can't seem to get the command right
>> in Stata
>>
>> isn't it reshape? bldg_id, zone_id and bldg_type are all strings
>
>
> No, you don't want to use -reshape-.  You want to use -expand- instead.  For
> example, the following will replicate the transformation you show above:
>
>    expand No_jobs
>    so bldg_id
>    gen job_id = _n
>
>
> -- Phil
>
> *
> *   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index