Home Forums ASDOC : Easy Publication Quality Tables in Stata asdoc in a loop with nest option in Stata

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Juan Miranda
    Post count: 118

    Dear Attaullah Shah, good afternoon.

    I’m a Stata user, but some programming things I do not understand yet.
    I’ve been looking at forums like https://stackoverflow.com/questions/53524560/looping-and-storing-beta-coefficients-after-regress-over-files#new-answer
    answer to a question I have.

    I am not able to make my loop save the results after regressing over files (betas, t, R2 and N), with all my datasets. I have 11 named 2005.dta to 2017.dta (except for 2009) contained in a folder (F:\datasets).

    The objective is to use asdoc, and to generate a summary table of the estimates I make. The code that I have written is the following.

    cd "F: \ datasets"
    local i: dir. files "* .dta"
    foreach file in `i' {
        asdoc reg and x1 x2 x3, append nest rep (t | se) ///
              title (Table 1 MCO per year) dec (3)

    But the result is that asdoc saves the results of a single database (only the first – 2005) 11 times and does nothing for the others.

    If you could have time to help me solve this problem I would thank you very much.

    Cheers Juan

    Attaullah Shah
    Post count: 69

    Juan Miranda: The question you have asked on StackOverflow is on hold, so I cannot add my answer there. The loop you are using does not use asdoc on each data set that you have. So the correct code would be:

    cd "F:\datasets"
    local i : dir "F:\datasets" files "*.dta"
    foreach file in `i' {
    use `file', clear
    asdoc reg y x1 x2 x3, append nest rep(t) title(Table 1 MCO per year) dec(3) save(reg)

    Please also note that there should be no space between rep and (t | se). The same applies to other options of asdoc.
    Also note: the option rep(t) is used to report t-statistics. Instead, if you want to report standard errors, you would use rep(se). However, you cannot use both rep(t|se). Perhaps, you copied this from the help file of asdoc, where the symbol pipe is used to denote that one of these can be used.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.