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: Reshape from long to wide and attaching Labels contained in a Variable.


From   Phil Schumm <[email protected]>
To   <[email protected]>
Subject   Re: st: Reshape from long to wide and attaching Labels contained in a Variable.
Date   Thu, 29 Aug 2013 18:15:32 -0500

On Aug 29, 2013, at 6:04 PM, Phil Schumm <[email protected]> wrote:
> Be that as it may, here is an answer based on my best guess for what you are trying to do:
> 
> 
>    reshape wide amount title, i(id) j(code) string
>    foreach var of varlist amount* {
>        loc code = subinstr("`var'","amount","",1)
>        loc tvar title`code'
>        lab var `var' "`=`tvar'[1]'"
>        ren `var' `code'
>        drop `tvar'
>    }


I forgot to mention that I'm making the following assumption prior to reshaping:

    bys code: ass title==title[1]

but if this is not true, then I don't know what you're trying to do.


-- Phil


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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