I have written codes to export regression model results to excel file, and the codes are:
Code:
version 14.0
putexcel set oddsratio.xlsx, replace sheet(class1)

capture drop j
gen j = 1

forvalues i = 1/20 {
    logistic sds gst if complete == 1 & _`i'_cmembership == 1
    putexcel A`j' = etable using oddsratio.xlsx, sheet(class1) modify
    replace j = j + 5
}
The idea is to run regression model on 20 different sub-sample (defined by the value of variable:_`i'_cmembership). Each set of result table takes up 3 lines, so I specified "j = j+5" to separate each set of table by two blank rows in the excel file. I did not get any error messages after running the codes, but each time I ended up with an empty excel sheet after multiple tries. I tried to trouble shoot, and found out if I typed the codes:
Code:
version 14.0
putexcel set oddsratio.xlsx, replace sheet(class1)

logistic sds gst if complete == 1 & _1_cmembership == 1
putexcel A1 = etable using oddsratio.xlsx, sheet(class1) modify
I can have results exported in excel. But when adding above codes into -forvalues- loop, no results were written in excel file. I could not figure out what is wrong with my codes. Would appreciate your help and any inputs.

Thank you in advance.

Best,
Mengmeng