Hello,
I have the following program:
Ideally, this would export a distinct spreadsheet for 1900, 1910, 1920, 1930, and 1940. Instead, it exports five spreadsheets (named ttest_1900, ttest_1910, etc.) five times, which all contain the same content. This occurs five times, with the existing spreadsheets being replaced each time through the loop. End the end, I am left with five spreadsheets (named ttest_1900, ttest_1910, etc.), all containing 1940 dated. Any advice on how to fix this is appreciated.
I have the following program:
Code:
program define saveTtest preserve keep mu_* sd_* N_* se_* p_* keep if _n==1 gen id=1 order id, first reshape long mu_1_ mu_2_ /// sd_1_ sd_2_ N_1_ N_2_ se_ p_, /// i(id) j(varnames) string order varnames, first rename mu_1_ mu_1 rename mu_2_ mu_2 rename sd_1_ sd_1 rename sd_2_ sd_2 rename N_1_ N_1 rename N_2_ N_2 rename se_ se rename p_ p drop id forval year==1900(10)1940 { export excel using "$saveDir/ttest_`year'.xlsx", /// sheet(data_`1') firstrow(var) sheetreplace } restore end
Comment