Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: reshape question


From   "Oleksandr Talavera, BC" <talaveol@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: reshape question
Date   Fri, 07 Feb 2003 17:21:11 -0500

Hi,
you can try to rename the variables:

*---------
local question 03 12
local wave a b c d e
foreach i of local question {
       foreach  j of local wave {
                   rename `j'`i'income income`i'`j'
                   rename `j'`i'ed ed`i'`j'
       }
}
*---------


and then reshape...

Best,
Sasha



Sarah A. Mustillo wrote:

Hi -

I am trying to reshape a dataset from wide to long and can't figure one small thing out. My variables are all named with the j identifier at the beginning of the variable, rather than at the end, e.g.,

a03income
b03income
c03income
d03income
e03income

a12ed
b12ed
c12ed
d12ed
e12ed

etc.

where a,b,c,d,e stands for wave. I want to:

reshape long [many variables], i(id) j(wave) string

but, of course, Stata seems to be looking to the end of my variables for the wave identifier when mine are at the beginning. I have been trying to use my limited programming skills to move the letter from the beginning to the end on all of the variables, but haven't been able to do it.

Any suggestions?

Thanks!

Sarah




Sarah A. Mustillo, Ph.D
Center for Developmental Epidemiology
Department of Psychiatry and Behavioral Sciences
Duke University School of Medicine
Box 3454
Durham NC 27710

919 687-4686 x234

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


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