Hi everyone,
I wrote codes (see below) to export stats results into different excel files and sheets (boys versus girls) accordingly but Stata gave me the error message "invalid file specification". I read through Stats manuscript carefully about the command, and also studied several examples from websites but still could not figure out the coding errors.
I much appreciate your help to debug my codes and I can learn from your inputs.
Thanks so much.
Best,
Mengmeng
---- Codes ----
forvalues i = 1/4 {
use `file`i'', clear
forvalues j = 0/1 {
if `i' == 1 & `j' == 0 {
putexcel set Kinshasa_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 1 & `j' == 1 {
putexcel set Kinshasa_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 2 & `j' == 0 {
putexcel set Shanghai_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 2 & `j' == 1 {
putexcel set Shanghai_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 3 & `j' == 0 {
putexcel set Cuenca_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 3 & `j' == 1 {
putexcel set Cuenca_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 4 & `j' == 0 {
putexcel set Malawi_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 4 & `j' == 1 {
putexcel set Malawi_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
}
}
I wrote codes (see below) to export stats results into different excel files and sheets (boys versus girls) accordingly but Stata gave me the error message "invalid file specification". I read through Stats manuscript carefully about the command, and also studied several examples from websites but still could not figure out the coding errors.
I much appreciate your help to debug my codes and I can learn from your inputs.
Thanks so much.
Best,
Mengmeng
---- Codes ----
forvalues i = 1/4 {
use `file`i'', clear
forvalues j = 0/1 {
if `i' == 1 & `j' == 0 {
putexcel set Kinshasa_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 1 & `j' == 1 {
putexcel set Kinshasa_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 2 & `j' == 0 {
putexcel set Shanghai_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 2 & `j' == 1 {
putexcel set Shanghai_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 3 & `j' == 0 {
putexcel set Cuenca_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 3 & `j' == 1 {
putexcel set Cuenca_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 4 & `j' == 0 {
putexcel set Malawi_corr.xlsx, sheet(boys) replace
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
else if `i' == 4 & `j' == 1 {
putexcel set Malawi_corr.xlsx, sheet(girls) modify
polychoric meanscore_power meanscore_voice meanscore_decision ///
if number_miss_overall == 0 & ia2gender == `j'
putexcel A2 = matrix(r(R)), names nformat("#.##")
}
}
}
Comment