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
Problem: no observations r(2000)Hello i'm making a dynamic panel and i want to estimate a model with pmg, mg and dfe. When I do th…
adding summary weight in metabolic scoreHi, I am trying to generate a metabolic syndrome score for the children aged 11 to 12 years using PC…
Validity of a model for a data set using prediction.Hi I have a question whether we can assess the validity of a model for a data set using prediction. …
Estimating FE model with -reg or -xtregDear, I am estimating a panel data fixed effects model (both year and industry). I am aware I can e…
Out-of-Sample Prediction using Multinomial Logit ModelHi I have a question about the out-of-sample prediction using multinomial logit model. <Situatio…
Subscribe to:
Post Comments (Atom)
0 Response to Problems corresponding to variable names in stata double-layer loops
Post a Comment