Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: RE: Problem with "reshape"


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: Problem with "reshape"
Date   Wed, 4 Oct 2006 18:17:08 +0100

I am not watching this thread closely, but -renpfix- is
among various tools that could be relevant. 

Nick 
n.j.cox@durham.ac.uk 

Jacki Buros
 
> I could be wrong, but I think reshape allows you to specify where the
> 'j' portion of the data resides within the variable name using the '@'
> symbol.
> 
> so, with data as you've described :
> 
> > > date  code1_varx     code1_vary   code2_varx  code2_vary
> > > 1990        10            20           10          30
> > > 1991        10            20           10          30
> 
> you could type
> 
>      . reshape long code@_varx code@_vary, i(id) j(code)
> 
> which should give you
> 
> > > date  code_varx     code_vary   code
> > > 1990        10            20           1
> > > 1990        10            30           2
> > > 1991        10            20           1
> > > 1991        10            30           2
> 
> then you would just have to rename each code_varx to varx to 
> vary, as follows:
> 
> unab codevars : code_*
> foreach V of local codevars {
>         local rename=subinstr("`V'","code_","",.)
>         rename `V' `rename'
> }

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index