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*
Expand observationsHello All, I have a dataset with the following structure: (besides 'revenue' there are several more…
metan command errorHi, I am trying to run an ado file that uses metan command. The ado file was written in Stata 10.1. …
Stata drops category of factor variable in logistic RegressionDear stata users, I am currently trying to run a binary logistic regression on survey data (n=19.35…
Heat Plot Code: * Example generated by -dataex-. To install: ssc install dataex clear input str10 CODICE byte…
Generating a variable based on consecutive observationsHi all, I want to create a variable that is based on consecutive observations in my panel data. If …
Subscribe to:
Post Comments (Atom)
0 Response to Rename the list of variables with the name of each sheet*
Post a Comment