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, is already up and running.

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

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

From   Amanda Fu <>
Subject   st:stubs, ending with some number, are not available for all waves :-reshape-
Date   Sat, 25 Feb 2012 21:38:51 -0500

Hi All,

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

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.

Any suggestions will be appreciated. Thank you!

Best wishes,
Amanda Fu
*   For searches and help try:

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