The # #syntax is useless for what you want. How would rename be expected to know that you want 3 1 4 6 5 2?
rename v# (v3 v1 v4 v6 v5 v2)should work (unless you have e.g. v7 too).
In what sense does it not "seem to work." For me it does exactly what you say you want to do:
. clear* . set obs 1 Number of observations (_N) was 0, now 1. . forvalues i = 1/7 < 2. gen `:word `i' of `c(alpha)'' = "originally `:word `i' of `c(alpha)''" 3. >. . list, noobs clean a b c d e f g originally a originally b originally c originally d originally e originally f originally g . . rename (a b c d g e f) (b c a e f d g) . . list, noobs clean b c a e d g f originally a originally b originally c originally d originally e originally f originally g
Please post back with example data that illustrates the problem you are having. Also show exactly the command you are using, and show exactly the output you are getting from Stata. And if it is not blatantly obvious, explain in what way what you are getting is not what you need.
Show your commands and Stata results by copying them from your Results window or log file to your clipboard, and then pasting here in the forum between code delimiters. Use the -dataex- command to show example data. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.
Added: Crossed with #2 and #3
Here is my data:
* Example generated by -dataex-. To install: ssc install dataex clear input str1 v1 byte v2 int v3 byte v4 long(v5 v6 v7 v8) byte(v9 v10 v11 v12 v13 v14 v15 v16) int(v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28) long(v29 v30) "C" 10 1936 1 0 0 0 0 0 0 0 0 0 0 0 0 486 468 18 487 121 119 2 121 607 587 20 608 13467 4950 "C" 10 1950 1 0 0 0 0 0 0 0 0 0 0 0 0 363 361 2 363 99 96 3 99 462 457 5 462 11266 3073 "C" 10 1950 1 0 0 0 0 0 0 0 0 0 0 0 0 875 875 0 876 231 222 9 230 1106 1097 9 1106 19972 7590 "C" 10 1955 1 0 0 0 0 0 0 0 0 0 0 0 0 1015 964 51 1029 209 192 17 212 1224 1156 68 1241 29097 6719 "C" 10 1956 1 0 0 0 0 0 0 0 0 0 0 0 0 95 95 0 95 30 24 6 30 125 119 6 125 2553 930 "C" 10 1957 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 6 1 0 1 1 8 7 1 8 120 17 "C" 10 1963 1 0 0 0 0 0 0 0 0 0 0 0 0 379 364 15 379 59 59 0 59 438 423 15 438 9467 1589 "C" 10 1965 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 6 3 2 1 3 10 9 1 10 154 71 "C" 10 1967 4 0 0 0 0 1 1 0 1 0 0 0 0 3 3 0 3 1 1 0 1 5 5 0 5 31 15 "C" 10 1969 1 0 0 0 0 0 0 0 0 0 0 0 0 8 8 0 8 5 4 1 5 13 12 1 13 125 124 "C" 10 1971 1 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0 6 2 1 1 2 8 7 1 8 96 28 "C" 10 1971 1 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0 6 3 2 1 3 9 8 1 9 96 42 "C" 10 1971 1 0 0 0 0 0 0 0 0 0 0 0 0 7 7 0 7 4 3 1 4 11 10 1 11 100 68 "C" 10 1972 3 0 0 0 0 1 1 0 1 1 0 1 1 5 5 0 5 1 0 1 1 8 6 2 8 115 10 "C" 10 1972 4 0 0 0 0 1 1 0 1 0 0 0 0 5 0 5 5 0 0 0 0 6 1 5 6 15 0 "C" 10 1972 1 0 0 0 0 0 0 0 0 0 0 0 0 7 7 0 7 9 6 3 9 16 13 3 16 208 278 "C" 10 1973 3 0 0 0 0 1 1 0 1 1 1 0 1 4 2 2 4 0 0 0 0 6 4 2 6 58 0 "C" 10 1973 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 6 3 2 1 3 10 9 1 10 80 40 "C" 10 1973 3 0 0 0 0 1 1 0 1 0 0 0 0 7 7 0 7 1 0 1 1 9 8 1 9 173 14 "C" 10 1974 1 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 3 7 4 3 7 10 7 3 10 72 174 "C" 10 1975 1 0 0 0 0 0 0 0 0 0 0 0 0 6 5 1 6 5 4 1 5 11 9 2 11 96 143 "C" 10 1975 1 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0 5 2 1 1 2 7 6 1 7 88 34 "C" 10 1976 3 0 0 0 0 1 1 0 1 0 0 0 0 4 4 0 4 2 1 1 2 7 6 1 7 72 32 "C" 10 1978 3 0 0 0 0 1 1 0 1 0 0 0 0 7 7 0 7 1 1 0 1 9 9 0 9 136 28 "C" 10 1978 1 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 4 3 2 1 3 7 4 3 7 62 61 "C" 10 1978 1 0 0 0 0 0 0 0 0 0 0 0 0 9 9 0 6 5 3 2 5 14 12 2 11 188 147 "C" 10 1978 4 0 0 0 0 1 0 1 1 0 0 0 0 6 3 3 6 1 0 1 1 8 3 5 8 84 8 "C" 10 1979 1 0 0 0 0 0 0 0 0 0 0 0 0 3 2 1 3 3 3 0 3 6 5 1 6 30 54 "C" 10 1979 1 0 0 0 0 0 0 0 0 0 0 0 0 11 10 1 11 0 0 0 0 11 10 1 11 273 0 "C" 10 1979 3 0 0 0 0 1 0 1 1 0 0 0 0 5 5 0 5 4 3 1 4 10 8 2 10 69 57 "C" 10 1981 1 0 0 0 0 0 0 0 0 0 0 0 0 17 17 0 17 19 16 3 19 36 33 3 36 416 539 "C" 10 1982 3 0 0 0 0 2 1 1 2 1 1 0 1 2 2 0 2 0 0 0 0 5 4 1 5 30 0 "C" 10 1982 4 0 0 0 0 0 0 0 0 0 0 0 0 231 217 14 271 28 26 2 37 259 243 16 308 7958 1091 "C" 10 1983 3 0 0 0 0 1 1 0 1 0 0 0 0 4 4 0 4 2 1 1 2 7 6 1 7 74 27 "C" 10 1983 1 0 0 0 0 0 0 0 0 0 0 0 0 11 11 0 11 7 6 1 7 18 17 1 18 183 137 "C" 10 1984 4 0 0 0 0 1 1 0 1 0 0 0 0 4 4 0 4 0 0 0 0 5 5 0 5 65 0 "C" 10 1986 3 0 0 0 0 1 1 0 1 0 0 0 0 10 8 2 8 4 2 2 4 15 11 4 13 112 49 "C" 10 1988 3 0 0 0 0 1 1 0 1 0 0 0 0 9 9 0 9 4 3 1 4 14 13 1 14 184 106 "C" 10 1990 1 0 0 0 0 0 0 0 0 0 0 0 0 11 11 0 11 3 2 1 3 14 13 1 14 214 219 "C" 10 1990 3 0 0 0 0 1 1 0 1 0 0 0 0 36 36 0 36 3 2 1 3 40 39 1 40 878 87 "C" 10 1990 4 0 0 0 0 1 1 0 1 0 0 0 0 34 34 0 32 6 5 1 6 41 40 1 39 754 185 "C" 10 1990 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 6 1 1 0 1 8 8 0 8 80 15 "C" 10 1991 3 0 0 0 0 1 1 0 1 0 0 0 0 64 64 0 64 2 1 1 2 67 66 1 67 1503 68 "C" 10 1991 4 0 0 0 0 1 1 0 1 0 0 0 0 31 31 0 31 2 1 1 2 34 33 1 34 722 52 "C" 10 1992 1 0 0 0 0 0 0 0 0 0 0 0 0 7 7 0 7 1 0 1 1 8 7 1 8 172 15 "C" 10 1992 1 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 3 3 2 1 3 6 5 1 6 29 29 "C" 10 1992 1 0 0 0 0 0 0 0 0 0 0 0 0 101 101 0 101 6 5 1 6 107 106 1 107 2756 105 "C" 10 1992 1 0 0 0 0 0 0 0 0 0 0 0 0 164 159 5 164 32 31 1 32 196 190 6 196 3570 1105 "C" 10 1994 1 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 3 2 0 2 2 5 3 2 5 63 45 "C" 10 1994 4 0 0 0 0 1 1 0 1 1 0 1 1 5 4 1 5 0 0 0 0 7 5 2 7 75 0 "C" 10 1995 3 0 0 0 0 1 1 0 1 0 0 0 0 10 10 0 13 1 0 1 1 12 11 1 15 354 10 "C" 10 1995 1 0 0 0 0 0 0 0 0 0 0 0 0 199 183 16 198 37 33 4 37 236 216 20 235 5093 1000 "C" 10 1995 4 0 0 0 0 1 1 0 1 0 0 0 0 22 19 3 22 14 13 1 14 37 33 4 37 404 397 "C" 10 1996 1 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 4 1 1 0 1 5 3 2 5 133 22 "C" 10 1996 3 0 0 0 0 1 0 1 1 1 1 0 1 4 4 0 4 1 0 1 1 7 5 2 7 68 12 "C" 10 1996 3 0 0 0 0 1 1 0 1 0 0 0 0 69 69 0 69 1 0 1 1 71 70 1 71 1372 18 "C" 10 1997 1 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 5 5 3 2 4 8 6 2 9 110 70 "C" 10 1997 1 0 0 0 0 0 0 0 0 0 0 0 0 22 22 0 22 4 3 1 4 26 25 1 26 352 80 "C" 10 1998 4 0 0 0 0 3 3 0 3 0 0 0 0 4 4 0 4 1 0 1 1 8 7 1 8 73 12 "C" 10 1998 3 0 0 0 0 1 1 0 1 0 0 0 0 11 10 1 11 2 2 0 2 14 13 1 14 150 28 "C" 10 1998 3 0 0 0 0 1 0 1 1 0 0 0 0 6 6 0 6 2 2 0 2 9 8 1 9 72 26 "C" 10 1999 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 5 3 2 1 4 10 9 1 10 71 67 "C" 10 2001 4 0 0 0 0 1 1 0 1 0 0 0 0 12 11 1 12 1 0 1 1 14 12 2 14 80 6 "C" 10 2001 1 0 0 0 0 0 0 0 0 0 0 0 0 11 11 0 11 10 6 4 10 21 17 4 21 320 262 "C" 10 2001 1 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0 6 3 2 1 3 9 8 1 9 72 46 "C" 10 2002 3 0 0 0 0 2 2 0 2 0 0 0 0 81 81 0 81 3 2 1 3 86 85 1 86 2292 83 "C" 10 2002 1 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 3 3 2 1 3 6 5 1 6 51 55 "C" 10 2002 1 0 0 0 0 0 0 0 0 0 0 0 0 20 20 0 20 9 8 1 9 29 28 1 29 435 135 "C" 10 2002 3 0 0 0 0 1 1 0 1 0 0 0 0 27 27 0 27 1 0 1 1 29 28 1 29 360 8 "C" 10 2002 4 0 0 0 0 1 0 1 1 0 0 0 0 5 5 0 5 0 0 0 0 6 5 1 6 27 0 "C" 10 2002 4 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 3 3 2 1 3 10 9 1 7 83 42 "C" 10 2002 3 0 0 0 0 2 2 0 2 0 0 0 0 10 10 0 10 5 3 2 5 17 15 2 17 119 60 "C" 10 2003 1 0 0 0 0 0 0 0 0 0 0 0 0 9 4 5 9 0 0 0 0 9 4 5 9 56 0 "C" 11 1989 1 0 0 0 0 0 0 0 0 0 0 0 0 18 18 0 18 19 18 1 19 37 36 1 37 455 426 "C" 11 1999 4 0 0 0 0 1 1 0 1 0 0 0 0 3 3 0 3 1 0 1 1 5 4 1 5 30 6 "C" 11 2001 1 0 0 0 0 0 0 0 0 0 0 0 0 34 32 2 30 13 12 1 12 47 44 3 42 389 207 "C" 12 1946 1 0 0 0 0 0 0 0 0 0 0 0 0 14 7 7 14 0 0 0 0 14 7 7 14 166 0 "C" 12 1948 1 0 0 0 0 0 0 0 0 0 0 0 0 29 29 0 29 6 4 2 6 35 33 2 35 928 192 "C" 12 1956 4 0 0 0 0 1 1 0 1 0 0 0 0 10 7 3 10 0 0 0 0 11 8 3 11 100 0 "C" 12 1957 4 0 0 0 0 1 1 0 1 0 0 0 0 9 4 5 9 0 0 0 0 10 5 5 10 78 0 "C" 12 1957 4 0 0 0 0 1 1 0 1 0 0 0 0 9 5 4 9 0 0 0 0 10 6 4 10 75 0 "C" 12 1960 3 0 0 0 0 2 1 1 2 0 0 0 0 6 6 0 6 0 0 0 0 8 7 1 8 27 0 "C" 12 1964 4 0 0 0 0 1 1 0 1 1 1 0 1 4 4 0 4 0 0 0 0 6 6 0 6 25 0 "C" 12 1964 1 0 0 0 0 0 0 0 0 0 0 0 0 7 4 3 7 8 8 0 8 15 12 3 15 96 210 "C" 12 1964 3 0 0 0 0 1 1 0 1 0 0 0 0 6 6 0 6 2 2 0 2 9 9 0 9 100 20 "C" 12 1965 1 0 0 0 0 0 0 0 0 0 0 0 0 42 42 0 42 7 5 2 7 49 47 2 49 663 126 "C" 12 1966 3 0 0 0 0 1 1 0 1 1 0 1 1 4 4 0 4 1 0 1 1 7 5 2 7 48 15 "C" 12 1967 4 0 0 0 0 2 1 1 2 0 0 0 0 19 19 0 19 1 0 1 1 22 20 2 22 388 18 "C" 12 1968 1 0 0 0 0 0 0 0 0 0 0 0 0 74 74 0 74 14 10 4 14 88 84 4 88 2167 558 "C" 12 1968 1 0 0 0 0 0 0 0 0 0 0 0 0 20 20 0 20 12 8 4 12 32 28 4 32 440 312 "C" 12 1969 4 0 0 0 0 1 1 0 1 0 0 0 0 4 4 0 4 0 0 0 0 5 5 0 5 42 0 "C" 12 1969 3 0 0 0 0 1 1 0 1 0 0 0 0 13 13 0 13 1 0 1 1 15 14 1 15 201 12 "C" 12 1970 4 0 0 0 0 2 1 1 2 0 0 0 0 3 3 0 3 0 0 0 0 5 4 1 5 18 0 "C" 12 1970 4 0 0 0 0 1 1 0 1 0 0 0 0 9 9 0 9 1 1 0 1 11 11 0 11 54 6 "C" 12 1971 1 0 0 0 0 0 0 0 0 0 0 0 0 10 6 4 10 4 4 0 4 14 10 4 14 136 70 "C" 12 1971 4 0 0 0 0 1 1 0 1 1 0 1 1 3 3 0 3 0 0 0 0 5 4 1 5 24 0 "C" 12 1972 3 0 0 0 0 1 1 0 1 0 0 0 0 7 7 0 7 7 6 1 7 15 14 1 15 140 139 "C" 12 1972 1 0 0 0 0 0 0 0 0 0 0 0 0 13 11 2 13 3 2 1 3 16 13 3 16 316 124 "C" 12 1972 1 0 0 0 0 0 0 0 0 0 0 0 0 33 17 16 33 24 16 8 20 57 33 24 53 586 373 "C" 12 1972 3 0 0 0 0 1 1 0 1 0 0 0 0 3 3 0 3 7 7 0 7 11 11 0 11 60 122 end label values v2 v2CD
All I want is to rename variables in following way: (change v24 to v25, v25 to v27, v26 to v28, v27 to v26, v28 to v24)