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 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]

Re: st:stubs, ending with some number, are not available for all waves :-reshape-


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st:stubs, ending with some number, are not available for all waves :-reshape-
Date   Sun, 26 Feb 2012 09:33:48 +0000

Your problem appears easier than that in the thread you cite.

reshape long firm wage hour, i(id) j(wave)

might well be sufficient.

Nick

On Sun, Feb 26, 2012 at 2:38 AM, Amanda Fu <mandy.fu1@gmail.com> wrote:

> The Statalist archive already has had extensive discussion on
> reshaping when the stubs are in the beginning of the variables names.
> http://www.stata.com/statalist/archive/2006-04/msg00960.html
>
>  I still have a question after checking the previous posts. I would
> like to reshape a wide (unbalanced panel data of  with 20 waves) data
> set into long structure. In the wide dataset all the time-variant
> variables are named ending with a number `k' , i=1,2,...19, 20. When
> some variables that are not available for some years, those variables
> are not existent at all for the years they are not available.
>
>
> The variables names are like ():
> ID,  firm1,wage1, hour2, firm2,wage2,............hour20, firm20
> (hour1 and wage20 do not exist because the information are not
> available for all waves.)
>
> The actual data set includes around 1000 time-variant variables. I
> would like to reshape the whole data sets into long , not just a few
> variables.
>
> What I tried is:
> ------------------------------------------------------
> unab var: *1
> local stubs: subinstr local vars "1" "",all
> reshape long `stubs',i(id) j(wave)
> -----------------------------------------------------
>  This causes problems for the variables that are not first created at
> wave 1. However, if I use 20 instead of 1, I got similar problem for
> those variables that are stopped being collected before wave 20.
>

*
*   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