⇤ ← Revision 1 as of 2023-01-14 20:10:09
Size: 1409
Comment:
|
Size: 1500
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
The '''`rename`''' command renames an existing variable. |
|
Line 11: | Line 13: |
To rename a variable, try: |
|
Line 15: | Line 15: |
}}} To rename multiple variables simultaneously, try: {{{ rename (VAR1 VAR2) (VAR2 VAR1) |
rename (OLDVAR1 OLDVAR2) (NEWVAR2 NEWVAR1) |
Line 42: | Line 37: |
Prior to then, these functions were filled by other commands: | ---- == Stata 12 Extensions == As noted above, various extensions were added to the `rename` command in Stata 12. Consider the following for backwards compatibility: |
Stata Rename
The rename command renames an existing variable.
Contents
Usage
rename OLDVAR NEWVAR rename (OLDVAR1 OLDVAR2) (NEWVAR2 NEWVAR1)
Stata 12+ supports additional functions:
// rename all variables with a leading 'q' such that the 'q' is replaced with a 'Q' rename q* Q* // rename all variables with a trailing '_r' such that the '_r' is replaced with a '_R' rename *_r *_R // add a prefix to all variable names rename * orig_* // strip a suffix from all variable names rename *_checked * // rename all variables to a lowercase name rename *, lower
Stata 12 Extensions
As noted above, various extensions were added to the rename command in Stata 12. Consider the following for backwards compatibility:
// rename all variables with a leading 'q' such that the 'q' is replaced with a 'Q' renpfix q Q // rename all variables with a trailing '_r' such that the '_r' is replaced with a '_R' search rensfix //STB59: needs to be manually installed rensfix _r _R // add a prefix to all variable names search renvars //STB60: needs to be manually installed renvars *, prefix(orig_) // strip a suffix from all variable names search rensfix //STB59: needs to be manually installed rensfix _checked // rename all variables to a lowercase name search renvars //STB60: needs to be manually installed renvars *, lower