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   Clyde B Schechter <clyde.schechter@einstein.yu.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re:st:stubs, ending with some number, are not available for all waves :-reshape-
Date   Sun, 26 Feb 2012 20:12:48 +0000

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

That's a good start.  Try this:

local stubs
forvalues i = 1/20 {
    unab this_round: *`i'
    local this_round: subinstr local this_round "`i'" "", all
    local stubs: list stubs| this_round
}
reshape long `stubs', i(id) j(wave)

Clyde Schechter
Dept. of Family & Social Medicine
Albert Einstein College of Medicine
Bronx, NY, USA


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