Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is wrong with my code?

    Hello,

    I need your help, what is wrong with my code?

    forvalues i=1(1)13 {
    foreach v of global VAR2 {
    quietly gen pval`v'`i' = 0
    quietly gen phet`v'`i' = 0
    }

    forvalues j=1(1)13 {


    quietly regress gdds`j' gdcm`j'
    quietly hettest, fstat
    quietly replace phetgd`j'=r(p)

    quietly regress pcds`j' pccm`j'
    quietly hettest, fstat
    quietly replace phetpc`j'=r(p)

    quietly regress ipds`j' ipcm`j'
    quietly hettest, fstat
    quietly replace phetip`j'=r(p)

    }


    forvalues j=1(1)13 {
    quietly regress gdds`j' gdcm`j', rob
    quietly test gdcm`j'=1
    quietly test _cons=0, accumulate
    quietly replace pvalgd`j'=r(p)
    quietly outreg2 using results/tabs/bias_gdp_rob, adds(F-test, r(F), Prob > F, `r(p)') excel

    quietly regress pcds`j' pccm`j', rob
    quietly test pccm`j'=1
    quietly test _cons=0, accumulate
    quietly replace pvalpc`j'=r(p)
    quietly outreg2 using results/tabs/bias_pc_rob, adds(F-test, r(F), Prob > F, `r(p)') excel

    quietly regress ipds`j' ipcm`j', rob
    quietly test ipcm`j'=1
    quietly test _cons=0, accumulate
    quietly replace pvalip`j'=r(p)
    quietly outreg2 using results/tabs/bias_ip_rob, adds(F-test, r(F), Prob > F, `r(p)') excel

    }


    Thank you for your support.
    Ibrahim

  • #2
    Where does it break down? What does Stata say?

    Comment


    • #3
      You are missing a right bracket after your intial block of code. It should look something like this
      Code:
      forvalues i=1(1)13 {
       foreach v of global VAR2 {
        quietly gen pval`v'`i' = 0
        quietly gen phet`v'`i' = 0
       }
      }
      This is a necessary condition for fixing the problem; whether it is sufficient I do not know.

      Comment


      • #4
        P.S. A nice feature of using Stata's do-file editor is that it "pairs up," using color coding, brackets and parentheses so you can see whether loops, nested parenthetical expressions, etc. are all appropriately nested. Even if you write your code elsewhere, I find that cutting and pasting it into the do-file editor can be very useful for this reason.

        Comment


        • #5
          Thanks a lot, it is working. I am using do-file editor. But the general problem was the outreg2. The problem is fixed now.

          Comment

          Working...
          X