Statalist


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

Re: st: Changing variable names


From   Henrik Stovring <hstovring@health.sdu.dk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Changing variable names
Date   Wed, 11 Jun 2008 10:22:45 +0200

Try this (where m is number of variables to rename):

forv i = 1/m {
   local newi = `i' + 55
   rename r`i' r`newi'
}

Best,

Henrik


Andri Rauch wrote:
Dear all,
I should increase the numbering in my variable names by a certain value (eg 55)
Eg: r1, r2, r3, r4, r5... should read r56, r57, r58, r59, r60...

Hope somebody can help.
Thanks in advance,
Andri

-----UrsprŘngliche Nachricht-----
Von: Andri Rauch Gesendet: 26 March 2008 12:12
An: 'statalist@hsphsun2.harvard.edu'
Betreff: Creating single characters from long strings

Dear all,
I should create single characters from very long strings (ie around 500 characters).
My original variable abcdefg... should be transformed to:
variable_1: a, variable_2: b, variable_3: c, variable_4: d and so on...

I assume it should be done by combining the substring and foreach command.

Hope that someone can help,

Thanks in advance
Andri

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

--
Henrik St°vring, PhD

Research Unit for General Practice
University of Southern Denmark J.B. Winsl°ws Vej 9A
DK-5000 Odense C
Phone: (+45) 6550 3692
Fax: (+45) 6591 8296 email: hstovring@health.sdu.dk
Homepage: http://www.almen.dk/hstovring
------------------------------------------------------------------

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