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:stubs, ending with some number, are not available for all waves :-reshape-


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st:stubs, ending with some number, are not available for all waves :-reshape-
Date   Sun, 26 Feb 2012 10:49:25 +0100

Amanda,

it seems your problem is to create a list of the variable-stubs you
want to -reshape-. There might be better alternatives but drawing on
what you have so far, here is something that should work

forv j = 1/20 {
    unab add : *`j'
    loc add : subinstr loc add "`j'" "" ,all
    loc stubs `stubs' `add'
}
loc stubs : list uniq stubs

reshape long `stubs' ,i(id) j(wave)

Best
Daniel

-- 
[...]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index