Announcement

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

  • regressing group observations identified by id in loop and for each regression create a table output

    Hello.
    I am trying to create some doc/docx regression table output for each group of observations that has a given id number (variable name of the id number is "order"). Ideally, each table output would have as title the id or the given string variables from which the id number is generated. So far I have tried (with little success) the following code:

    forval y = 1/`r(max)' {
    regress y x1 x2...., vce(hc3) if order ==`i'
    outreg2 using tryoutreg.doc, append ctitle(order)
    }
    In particular, stata does not accept the use of "if"...

    Thank you. I have lost a lot of time without finding an appropriate solution, trying foreach, forval, and others.
    Kind regards.

  • #2
    In particular, stata does not accept the use of "if"...
    "If" is not an option so moving that before the comma should work. Aka:

    Code:
    reg y a b c, vce(hc3) if order == 1  // this will not work
    reg y a b c if order == 1, vce(hc3)  //this should work

    Comment


    • #3
      Another problem in #1 is that the local macro i does not match the name y used to open the loop.

      Comment


      • #4
        Thank you!

        Comment

        Working...
        X