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!
Related Posts with How to write a loop code for this following case as detailed in the post?
Country-pair specific id for gravity modelHello all, I'm trying to estimate a gravity model with trade data that is disaggregated at industry…
Describe variablesI have a dataset (example below) and I would like to know the frequency of males (sex==1) and female…
Sactter plot with different groups while adding label for one particular observation (sepscatter command)Hi everyone, I have a cross section data for a group of countries and three variables: government s…
How to merge datasets using joinby?I have the following data. In Data set A, I have rows of children with "h13hhidc" indicating their h…
How to perform relative mortality in STATA?Hi Everyone. I have a dataset of cancer patients from 2004-2014 with survival status until 2015. Now…
Subscribe to:
Post Comments (Atom)
0 Response to How to write a loop code for this following case as detailed in the post?
Post a Comment