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
Difference in proportion adjusted for baseline characteristics (Mantel Haenszel method)Hi, I am analysing the results of a trial & would like to compare the proportion of individuals…
.ado Programming in Stata without invoking mata: Invalid Name error from within the functionStata Status: Beginner I have declared a local variable inside my function. And whenever I referenc…
Variable Significance Changes After Adding Regional DummiesDear All, I have two simple yet complicated question. I run my regressions on survey data using th…
Take the latest observation per fiscal-periodHi, I want to take (or mark) the latest forecast (variable= forecast_date) per fiscal-period (varia…
Help required for variable forecast procedureDear All I need some help with commands relating to earnings forecasts model: EARN(t+1)=b0+ b1EARN…
Subscribe to:
Post Comments (Atom)
0 Response to Problems corresponding to variable names in stata double-layer loops
Post a Comment