I encountered a problem in the process of data merging. I put 5 control variables into 5 sheets of an excel table. After converting the panel data, I want to put the corresponding variable name in each sheet.After changing it, although the variable name has been changed, the dta name has also been changed, and the dta data generated all have become the data in the last sheet. Please help me and answer it, thank you very much! ! ! ! (below is the stata code I wrote)
local x cpi house profits population rgdp
forvalues i = 1/5{
foreach m of local x{
import excel using control.xlsx,sheet(Sheet`i') first clear
reshape long M, i(province) j(year)
rename M `m'
save `m'.dta,replace
}
}
Related Posts with Problems corresponding to variable names in stata double-layer loops
Comparing classes in a Latent Profile ModelDear all, I am trying to determine the number of groups or classes for a latent variable using seve…
STATA putdocxHi everyone, I am trying to create a report with putdocx. I have managed to put percentages in a tab…
Distribution Dependent variableHello, does someone know how to determine the distribution of the dependent variable? I am not sure…
Reshape long WDI(World Bank) dataHi,Statalist. I want to reshape long the data of WDI to panel data.This is the example data. Code: …
many-to-many merge problemHi, I have the following data that I want to merge: Master dataset: statalist_data4.dta Code: * Ex…
Subscribe to:
Post Comments (Atom)
0 Response to Problems corresponding to variable names in stata double-layer loops
Post a Comment