I want to rename variables:
rename f120_0_s1 f120_s1_0_
rename f120_1_s1 f120_s1_1_
rename f120_2_s1 f120_s1_2_
rename f120_3_s1 f120_s1_3_
rename f120_4_s1 f120_s1_4_
rename f120_5_s1 f120_s1_5_
rename f120_6_s1 f120_s1_6_
rename f120_7_s1 f120_s1_7_
rename f120_8_s1 f120_s1_8_
rename f120_9_s1 f120_s1_9_
rename f120_10_s1 f120_s1_10_
rename f120_11_s1 f120_s1_11_
rename f120_12_s1 f120_s1_12_
rename f120_13_s1 f120_s1_13_
rename f120_14_s1 f120_s1_14_
rename f120_15_s1 f120_s1_15_
rename f120_0_s2 f120_s2_0_
rename f120_1_s2 f120_s2_1_
rename f120_2_s2 f120_s2_2_
rename f120_3_s2 f120_s2_3_
rename f120_4_s2 f120_s2_4_
rename f120_5_s2 f120_s2_5_
rename f120_6_s2 f120_s2_6_
rename f120_7_s2 f120_s2_7_
rename f120_8_s2 f120_s2_8_
rename f120_9_s2 f120_s2_9_
rename f120_10_s2 f120_s2_10_
rename f120_11_s2 f120_s2_11_
rename f120_12_s2 f120_s2_12_
rename f120_13_s2 f120_s2_13_
rename f120_14_s2 f120_s2_14_
rename f120_15_s2 f120_s2_15_
…
till s17
How to write loop code for this or any other parsimonious ways? I tried the following, but obviously there is something wrong:
forvalues i = 0/15 j = 1/17 {
rename f120_`i’_s`j’ f120_s`j’_`i’_
}
Many thanks!
0 Response to How to write a loop code for this following case as detailed in the post?
Post a Comment