I flagged that I was referring to -renvars- from the Stata Journal and
recommended using -search- for locations. Kit Baum also underlined that
the command is to be found in the Stata Journal files.
Sergiy evidently did not follow that advice. Suppose you did:
. search renvars
Keyword search
Keywords: renvars
Search: (1) Official help files, FAQs, Examples, SJs, and
STBs
Search of official help files, FAQs, Examples, SJs, and STBs
SJ-5-4 dm88_1 . . . . . . . . . . . . . . . . . Software update for
renvars
(help renvars if installed) . . . . . . . . . N. J. Cox and J.
Weesie
Q4/05 SJ 5(4):607
trimend() option added and help file updated
STB-60 dm88 . . . . . . . . Renaming variables, multiply and
systematically
(help renvars if installed) . . . . . . . . . N. J. Cox and J.
Weesie
3/01 pp.4--6; STB Reprints Vol 10, pp.41--44
renames variables by changing prefixes, postfixes, substrings,
or as specified by a user supplied rule
That is, the latest version of -renvars- may be downloaded from the
files for SJ 5(4).
Why did Sergiy get his results? As he indicates clearly, for some reason
he is using this earlier version:
renvars from http://www.fss.uu.nl/soc/iscore/stata
renvars. Powerful command to rename variables. / renvars renames
the
variables in a varlist by any of a number of / functions, case
conversion,
pre- and postfixing of strings, and / substitutions within variable
names.
/ Author: Jeroen Weesie, Dept of Sociology, Utrecht University (NL)
/
There are various good reasons why you might use that version:
1. You are still using Stata 6. The 2001 version requires Stata 7. The
2005 version requires 8.
2. You downloaded the version from Jeroen's site some while ago and it
is fine for your purposes.
3. You don't like later versions.
But that's as may be. My examples didn't work with Sergiy's version
because the syntax has changed. Again, I did recommend the Stata
Journal version, and neglected to explain the complete history of
-renvars- and its predecessors, which isn't very interesting.
I note his "preferred strategy" with interest. Incidentally, wiring -ds-
into a program is inefficient. As I've already indicated in this thread,
you can go straight to a full list of variables using * or _all. -ds-
just adds interpretative overhead; it is useful for other problems, and
I use it myself, and am one of its authors, but it's not the best route
to follow here.
I believe that the code Jeroen Weesie and I published in 2001 and 2005
avoids most of the obvious pitfalls with renaming. If Sergiy can find
any bugs or inconsistencies in the 2005 version, he should naturally let
us know.
Nick
[email protected]
Sergiy Radyakin
Does not seem to work:
//-----------------------------------------------------
clear
sysuse auto
renvars \ var1-var`c(k)'
\ invalid name
r(198);
renvars var1-var`c(k)'
r(111);
renvars * var1-var`c(k)'
variable var1 not found
r(111);
which renvars
c:\ado\plus\r\renvars.ado
*! 2.2.1 15aug2000 Jeroen Weesie/ICS
version
version 9.2
*************************************************************
Perhaps I am doing something wrong?? Is slash required? Did you mean
-renamev- ?