Bookmark and Share

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

[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 <>
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.


On Sun, Feb 26, 2012 at 2:38 AM, Amanda Fu <> wrote:

> The Statalist archive already has had extensive discussion on
> reshaping when the stubs are in the beginning of the variables names.
>  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:

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