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
Estimates post: matrix has missing values! for ivreg2Hi, guys! I received an error message "estimates post: matrix has missing values" when i'm using iv…
Graph with restricted range in y-axis?Dear All, I follow this thread (https://www.statalist.org/forums/for...control-method) and got the f…
Missing AR 1 and 2 Code: ------------------------------------------------------------------------------ Group variab…
Rolling corelation Dear Stata Users 1. I need to calculate a rolling correlation for variable eret with marketreturn …
Tabout 3 summary statistics transposing columns to rowsHi Statalist, I am using Stata 15 and I have a question related to tabout 3. I want to make a tabl…
Subscribe to:
Post Comments (Atom)
0 Response to Problems corresponding to variable names in stata double-layer loops
Post a Comment