Hello,
I am using Stata 11 and have a set of variables that use underscores, see list below:
_401
_402
_402_1
_402_2
_403
_403a
_403b
I would like to rename the variables so that underscores are removed and replaced with an 's' in front of the variables, as shown below:
s401
s402
s402_1
s402_2
s403
s403a
s403b
Is there any way to rename this set of variables at once instead of renaming them one by one? I have tried the 'foreach' command but it seems that the underscores or letters at the end in some of them (e.g. _402_1 or _403a) create a problem and Stata returns an error.
Thank you!
Carr
I am using Stata 11 and have a set of variables that use underscores, see list below:
_401
_402
_402_1
_402_2
_403
_403a
_403b
I would like to rename the variables so that underscores are removed and replaced with an 's' in front of the variables, as shown below:
s401
s402
s402_1
s402_2
s403
s403a
s403b
Is there any way to rename this set of variables at once instead of renaming them one by one? I have tried the 'foreach' command but it seems that the underscores or letters at the end in some of them (e.g. _402_1 or _403a) create a problem and Stata returns an error.
Thank you!
Carr
Comment