Announcement

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

  • help with making automated tables in stata

    I am working on a project running regression models for 10 dependent variables and I need to do subgroup analysis for several subgroups: race/ethnicity, gender, marital status, and education level. Currently I am using esttab to output the results into excel. I saved each subgroup category for the 10 dependent variables as one excel file. Since there are so many subgroups, I had to save the results to many excel files and manually to copy the coefficients for my key dependent variables into one big table. It is very time intensive and if I update the model, I need to do it from the beginning. I did this automatically in SAS using ODS function, and macro, and output the results as a SAS data file, then worked on the data file to create the final table for publication automatically. However some of the analyses are easier to do in STATA. I am wondering whether there are ways in stata that i can create the results as a dataset automatically and worked on it to format for publication, or can I output the needed coefficient to an excel file and designate a cell place for the coefficients?

    Thanks everybody for help!

    Rui

  • #2
    the regression modes are the same for the 10 dependent variables.

    Comment


    • #3
      It seems to me you are not making effective use of esttab. You can store the results of each of your 10 regressions using eststo and then use esttab to create a single table with all 10 results.

      Here is a simple example you can run that demonstrates the technique. Do fully read the output of help esttab; the technique I show is the same as the first example in that documentation.
      Code:
      cls
      sysuse auto, clear
      regress weight length
      eststo reg1
      regress turn length
      eststo reg2
      esttab reg1 reg2
      Code:
      . esttab reg1 reg2
      
      --------------------------------------------
                            (1)             (2)   
                         weight            turn   
      --------------------------------------------
      length              33.02***        0.171***
                        (24.76)         (14.58)   
      
      _cons             -3186.0***        7.557** 
                       (-12.63)          (3.41)   
      --------------------------------------------
      N                      74              74   
      --------------------------------------------
      t statistics in parentheses
      * p<0.05, ** p<0.01, *** p<0.001

      Comment


      • #4
        Thanks!

        Is there anyway to export the results to different tabs in the same excel file? In the subgroup analysis, i used interaction terms so for different subgroups the dependent variables were different. I cannot put the in the same esttab line. I would like to put each subgroup results into a tab. I used insheet, but it only record the last regression model. i might do it wrong.

        Comment


        • #5
          I'm not sure I understand what you have attempted, nor what you seek.

          I would like to put each subgroup results into a tab. I used insheet, but it only record the last regression model.
          The insheet command (an outdated command) will import from an Excel worksheet, not export, so it is not clear to me what you have done.

          In the subgroup analysis, i used interaction terms so for different subgroups the dependent variables were different. I cannot put the in the same esttab line.
          It doesn't matter whether the dependent or independent variables are the same or different, esttab will create the appropriate table.
          [CODE
          ]sysuse auto, clear
          regress weight length
          eststo reg1
          regress turn headroom
          eststo reg2
          esttab reg1 reg2
          [/CODE]
          Code:
          . esttab reg1 reg2
          
          --------------------------------------------
                                (1)             (2)   
                             weight            turn   
          --------------------------------------------
          length              33.02***                
                            (24.76)                   
          
          headroom                            2.207***
                                             (3.98)   
          
          _cons             -3186.0***        33.04***
                           (-12.63)         (19.15)   
          --------------------------------------------
          N                      74              74   
          --------------------------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001


          Comment

          Working...
          X