Bookmark and Share

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: st: reshape data


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: reshape data
Date   Sat, 24 Jul 2010 13:29:46 -0500

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index