asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › error 3301 when running a loop
Tagged: 3301 loop
-
AuthorPosts
-
Dear Dr. Shah,
I am trying to use asdocx within a loop, but for some unknown reason it turns following error in the middle (!) of the loop (after going already successfully through 2 complete loop rounds, so for 2 out of 8 DVs):
asdocx_func_nested_reg(): 3301 subscript invalid
<istmt>: – function returned error
r(3301);My code:
// at the begining, I define through “local” the following macroses: DVs (8 of possible values: tobinq1 tobinq2 tobinq3 tobinq4 tobinq1_ln tobinq2_ln tobinq3_ln tobinq4_ln), controls, Model1, Model2, Model3, Model4, Model5, Model6, ModelN (it just equals 6) //
foreach DV of local DVs {
local Mymodel “OLSr”
forv i = 1/`ModelN’ {
asdocx regDV'
Modeli''
controls’, vce (robust), nest drop(i.fyear i.sic_2) cnames(Modeli') save(Model results2.docx) table_layout(autofit) landscape tzok dec(2) fs(8) add(Year dummy, Yes, Industry dummy, Yes) title(Coefficient Estimates from
Mymodel’ regression on `DV’) label
asdocx regDV'
Modeli''
controls’, vce (robust), nest drop(i.fyear i.sic_2) cnames(Modeli') save(Model results2.xlsx) tzok dec(2) title(Coefficient Estimates from
Mymodel’ regression on `DV’)
}
local Mymodel “FE”
forv i = 1/`ModelN’ {
asdocx xtregDV'
Modeli''
controls’, fe vce (robust), nest drop(i.fyear i.sic_2) cnames(Modeli') save(Model results2.docx) table_layout(autofit) landscape tzok dec(2) fs(8) add(Year dummy, Yes, Industry dummy, Yes) title(Coefficient Estimates from
Mymodel’ regression on `DV’) label
asdocx xtregDV'
Modeli''
controls’, fe vce (robust), nest drop(i.fyear i.sic_2) cnames(Modeli') save(Model results2.xlsx) tzok dec(2) title(Coefficient Estimates from
Mymodel’ regression on `DV’)
}
}As you can see above, I am trying to get output both as excel and word (though I have tried to use them separately as well). Word option (even if I use it without the lines for excel outputs) crushes each time with the 3301 error in the middle of the loop. And the excel option creates unexpected outcomes (again – even if I use it separately from the word-output-creating code) – a table with too many columns where one cannot follow what outcome is from what model…
The Word asdcox option works well only if I do not loop over different DVs… when this complexity is added – model stops with 3301 error after a few loops.FYI: without using asdocx (e.g. having standard output, e.g. in html, or just in the Results window) the whole loop runs smoothly. It crushes only when I try to use asdoc or asdocx.
Do you have any hints how this could be fixed? Would very much appreciate your help here.
Can you please send me the data that creates the above error. my email address is attaullah.shah@imsciences.edu.pk
-
AuthorPosts
- You must be logged in to reply to this topic.