Announcement

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

  • if clause not allowed within option command error

    Dear all,

    When creating a table summarising my regression results, I keep on receiving " 'if' clause not allowed within option command r199" error message. All I want is to combine 3 tables with 3 different regressions into one and then customise it - the code I am running is below

    Code:
    table () () (), command(xtreg wages i.high_qual training_hrs if job_type==1, re vce(robust)) command(xtreg wages i.high_qual training_hr
    > s i.sex i.region i.age i.sector if job_type==1, re vce(robust)) command(xtreg wages i.high_qual training_hrs i.illness_disability i.sex 
    > i.children i.general_health i.region i.age i.sector if job_type==1, re vce(robust))
    Could anyone kindly suggest how I can solve this problem? Thank you in advance!

  • #2
    Hi!

    I think you should be able to use a program like estout to create your regression table.

    http://repec.sowi.unibe.ch/stata/estout/index.html

    Basically, put eststo: before each regression to store the estimates, and then you can use esttab to create your table. See the help file for more options.

    Comment


    • #3
      thank you Lizzy Padhi for your recommendation! it worked!
      Last edited by sladmin; 25 Apr 2022, 08:27. Reason: anonymize original poster

      Comment


      • #4

        One last question, Lizzy Padhi - the regression table esttab command generated does not specify categories within a variable by name. For example, instead of "Degree" or "Other Higher degree" it simply says "1.high_qual" and "2.high_qual"

        Code:
        . esttab, se ar2
        
        ------------------------------------------------------------
                              (1)             (2)             (3)   
                            wages           wages           wages   
        ------------------------------------------------------------
        1.high_qual             0               0               0   
                              (.)             (.)             (.)   
        
        2.high_qual        -3.817***       -2.240***       -2.186***
                          (0.109)         (0.129)         (0.149)   
        
        3.high_qual        -5.405***       -3.092***       -2.839***
                         (0.0845)         (0.107)         (0.126)   
        
        4.high_qual        -6.470***       -4.182***       -3.810***
                         (0.0822)         (0.113)         (0.130)   
        
        5.high_qual        -7.475***       -5.069***       -4.469***
                         (0.0946)         (0.151)         (0.167)   
        
        9.high_qual        -9.105***       -6.653***       -5.589***
                         (0.0776)         (0.168)         (0.190)   
        
        training_hrs      0.00142***     0.000908***     0.000459*  
                       (0.000159)      (0.000163)      (0.000224)   
        
        1.sex                                   0               0   
                                              (.)             (.)   
        
        2.sex                              -1.552***       -2.088***
                                         (0.0767)        (0.0925)   
        
        1.region                                0               0   
                                              (.)             (.)   
        
        2.region                          -0.0976          0.0396   
                                          (0.213)         (0.221)   
        
        3.region                           -0.384          -0.310   
                                          (0.225)         (0.228)   
        
        4.region                           -0.369          -0.223   
                                          (0.219)         (0.229)   
        
        5.region                            0.150           0.386   
                                          (0.219)         (0.233)   
        
        6.region                            0.588*          0.834***
                                          (0.228)         (0.235)   
        
        7.region                            0.772***        1.166***
                                          (0.218)         (0.230)   
        
        8.region                            0.920***        1.235***
                                          (0.219)         (0.231)   
        
        9.region                           -0.567*         -0.407   
                                          (0.228)         (0.238)   
        
        10.region                          -0.542*         -0.656** 
                                          (0.218)         (0.229)   
        
        11.region                           0.784***        0.676** 
                                          (0.223)         (0.229)   
        
        12.region                         -0.0444          -0.418   
                                          (0.217)         (0.227)   
        
        1.age                                   0                   
                                              (.)                   
        
        2.age                                   0               0   
                                              (.)             (.)   
        
        3.age                               0.948***        1.350***
                                          (0.213)         (0.359)   
        
        4.age                               2.267***        2.674***
                                          (0.216)         (0.337)   
        
        5.age                               4.038***        4.260***
                                          (0.218)         (0.338)   
        
        6.age                               5.593***        5.753***
                                          (0.222)         (0.340)   
        
        7.age                               6.690***        6.792***
                                          (0.222)         (0.343)   
        
        8.age                               7.180***        7.312***
                                          (0.220)         (0.342)   
        
        9.age                               7.595***        7.305***
                                          (0.220)         (0.342)   
        
        10.age                              7.759***        6.934***
                                          (0.221)         (0.341)   
        
        11.age                              7.583***        6.452***
                                          (0.226)         (0.347)   
        
        12.age                              6.613***        4.970***
                                          (0.238)         (0.367)   
        
        13.age                              3.600***        0.225   
                                          (0.286)         (0.449)   
        
        1.sector                                0               0   
                                              (.)             (.)   
        
        2.sector                            0.572**         0.766** 
                                          (0.203)         (0.254)   
        
        3.sector                           -0.666***       -0.868***
                                          (0.201)         (0.249)   
        
        4.sector                           -4.575***       -5.175***
                                          (0.211)         (0.263)   
        
        5.sector                           -1.997***       -2.505***
                                          (0.212)         (0.258)   
        
        6.sector                           -2.261***       -2.844***
                                          (0.240)         (0.284)   
        
        1.illness_~y                                            0   
                                                              (.)   
        
        2.illness_~y                                        0.145*  
                                                         (0.0686)   
        
        0.children                                              0   
                                                              (.)   
        
        1.children                                         -0.567***
                                                          (0.112)   
        
        2.children                                         -1.363***
                                                          (0.165)   
        
        3.children                                         -2.657***
                                                          (0.335)   
        
        4.children                                         -3.124***
                                                          (0.512)   
        
        5.children                                         -4.184** 
                                                          (1.297)   
        
        6.children                                         -3.612   
                                                          (1.967)   
        
        1.general_~h                                            0   
                                                              (.)   
        
        2.general_~h                                       -0.194** 
                                                         (0.0693)   
        
        5.general_~h                                       -0.567** 
                                                          (0.175)   
        
        _cons               10.07***        8.416***        9.886***
                         (0.0712)         (0.333)         (0.453)   
        ------------------------------------------------------------
        N                  271700          139878           54027   
        adj. R-sq                                                   
        ------------------------------------------------------------
        Standard errors in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        Is there any way to modify and ensure that the correct names are specified within the regression results? The stata manual does not seem to cover this point

        Thank you in advance!

        Comment


        • #5
          Code:
          esttab, se ar2 label
          The reference is:

          Code:
          help estout
          or

          Code:
          help esttab

          Comment


          • #6
            thank you very much, Andrew Musau!

            Comment

            Working...
            X