Hi, I am importing 3 sheets from excel and I want to rename the list of variables with the name of each sheet
In my do I have:
cd "D:\Do\Mat"
local hojas "RB RM RA"
foreach i of local hojas {
import excel "\BDMattt2019.xlsx", sheet("`i'") firstrow clear
...
....
....
save "P_`i'.dta",replace
My vars are 20 : from INI_CDT_INT_EIB_0200_F_4 to INI_CDT_INT_EIB_4700_F_5
Using one var it would be :
rename INI_CDT_INT_EIB_0200_F_4 INI_CDT_INT_EIB_0200_F_4_R_`i',
but I want to reply this in all vars(20) for each sheet.
I want this results in my first database ( P_RB):
Id INI_CDT_INT_EIB_0200_F_4_R_RB INI_CDT_INT_EIB_4700_F_5_R_RB
1
2
3
4
.
.
.
In my second database ( P_RM):
Id INI_CDT_INT_EIB_0200_F_4_R_RM INI_CDT_INT_EIB_4700_F_5_R_RM
1
2
3
4
.
.
.
In my second database ( P_RA):
Id INI_CDT_INT_EIB_0200_F_4_R_RA INI_CDT_INT_EIB_4700_F_5_R_RA
1
2
3
4
.
.
.
Kind Regards,
Sumiko.
Related Posts with Rename the list of variables with the name of each sheet*
FE approach to nonlinear panel data - Is a Two-part model compatible?Dear Stata users, I have 31000 country-pairs (panel variable) during 17 years (time variable) and m…
Manipulating box plotsGood morning, Is it possible to redefine box plots, for example to have something more meaningful th…
Same data, same code, same stata version, different computers, different resultsDear all, I am running a production function estimation based on maximum likelihood. The code is as…
Comparing groups at timepoints after using MI and mixedHello, I am currently looking at a scale (PDI) measured every third month over a year (baseline, 3-,…
Unusual font in the imported fileCould you please help me sort this out. The dta file after I import xlsx file shows the font in diff…
Subscribe to:
Post Comments (Atom)
0 Response to Rename the list of variables with the name of each sheet*
Post a Comment