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   Amanda Fu <mandy.fu1@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 11:39:45 -0500

Hello Mr. Cox and Klein,

Thank you both for your help! Now I realized I did not fully
understand the "stack" of local names. That causes I could not figured
out the solution by myself.  Based on your suggestions, my problem is
solved. Thank you!

Amanda

On Sun, Feb 26, 2012 at 4:49 AM, daniel klein
<klein.daniel.81@googlemail.com> wrote:
> 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/

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