With this proposal, you have less hassle, so use this one before you try
mine :-) I would be very careful though as -capture- suppresses any error
that occurs along the way. So with a more complicated -numlist- to loop
over, my solution would probably let you sleep better at night :-)
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kieran McCaul
Sent: Monday, August 25, 2008 2:39 PM
To: [email protected]
Subject: st: RE: Foreach and rename
forvalues i=1/9 {
capture rename moi0`i'008 date_modif_`i'
}
______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul
_______________________________________________
The fact that no one understands you doesn't make you an artist.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Monday, 25 August 2008 8:28 PM
To: [email protected]
Subject: st: Foreach and rename
Dear all,
I'd like to change the name of many variables in this way:
rename moi01008 date_modif_1
rename moi02008 date_modif_2
rename moi03008 date_modif_3
rename moi05008 date_modif_5
rename moi06008 date_modif_6
rename moi09008 date_modif_9
I'd like to use a loop, like
forvalues i=1/9 {
rename moi0`i'008 date_modif_`i'
}
But it doesn't work : "invalid syntax"
Even if this loop works, I have a problem with the value i=4,7 and 8 for
which moi0`i' does not exist.
How can I do ?
Thanks
Alvine
*****************************************************
Alvine BISSERY
Ing�nieur statisticien
Service de Biostatistique des Hospices Civils de Lyon
162 Avenue Lacassagne
69424 Lyon Cedex 03 - France
t�l: +33 4 72 11 57 55
fax: +33 4 72 11 51 41
*
* 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/
*
* 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/