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
how could the difference of number of a variable in a panel data be shown in statahello, i want to see how many people' living status(dummy variable) have been changed using a 2-peri…
create the day before a dateHello! I'm still working with dates and now have a new problem. If I have a date 22dec2014, I want …
Turning variable labels into variable names with a suffixHi I have data where my years are recorded in letters from H to CC (representing 1948 to 2021). The …
Storing output from did_imputation to later run event_plot commandI would like to save the results of `did_imputation` to be used later when generating coefficient pl…
Adding multiple labels to regsaveI am saving coefficients using regsave (from ssc) and I am able to use the 'addlabel' option to add …
Subscribe to:
Post Comments (Atom)
0 Response to Problems corresponding to variable names in stata double-layer loops
Post a Comment