Announcement

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

  • Saving meta analysis results using est store --> etable

    Hello! Is there a way to save meta analysis results, e.g. from meta esize or meta summarize?

    est store (and hence est table or etable) does not appear to work with the meta commands.

    Thank you for any thoughts that you have.

  • #2
    meta esize stores results in the dataset, so you just need to get these results into a matrix and subsequently use collect. You can explore the ideas presented here for meta summarize as well.

    Code:
    webuse metaesbin, clear
    meta esize tdead tsurv cdead csurv
    rename _meta_* *
    mkmat es - studysize, mat(meta) rownames(study)
    collect clear
    collect create metares
    collect get res= meta, name(metares)
    
    *OUTPUT RESULTS (STUDIES IN COLUMNS)
    collect style cell, nformat(%5.2f)
    collect style cell colname[studysize], nformat(%5.0f)
    collect layout (colname) (rowname)
    
    *OUTPUT RESULTS (STUDIES IN ROWS)
    collect style header colname, level(value)
    collect layout (rowname) (colname)
    Res.:

    Code:
     *OUTPUT RESULTS (STUDIES IN COLUMNS)
    
    .
    . collect style cell, nformat(%5.2f)
    
    .
    . collect style cell colname[studysize], nformat(%5.0f)
    
    .
    . collect layout (colname) (rowname)
    
    Collection: metares
          Rows: colname
       Columns: rowname
       Table 1: 5 x 4
    
    -----------------------------------------------------------------------
                                          | Study_1 Study_2 Study_3 Study_4
    --------------------------------------+--------------------------------
    Log odds-ratio                        |   -0.60    0.35    0.78   -2.57
    Std. err. for log odds-ratio          |    0.75    1.46    0.41    1.06
    95% lower CI limit for log odds-ratio |   -2.08   -2.51   -0.03   -4.64
    95% upper CI limit for log odds-ratio |    0.88    3.21    1.59   -0.50
    Sample size per study                 |     676     712     720     722
    -----------------------------------------------------------------------
    
    .
    .
    .
    . *OUTPUT RESULTS (STUDIES IN ROWS)
    
    .
    . collect style header colname, level(value)
    
    .
    . collect layout (rowname) (colname)
    
    Collection: metares
          Rows: rowname
       Columns: colname
       Table 1: 4 x 5
    
    ------------------------------------------
            |    es   se   cil   ciu studysize
    --------+---------------------------------
    Study_1 | -0.60 0.75 -2.08  0.88       676
    Study_2 |  0.35 1.46 -2.51  3.21       712
    Study_3 |  0.78 0.41 -0.03  1.59       720
    Study_4 | -2.57 1.06 -4.64 -0.50       722
    ------------------------------------------
    
    .
    If you need additional formatting for the table, that is a collect editing question, and you can start a new thread if you cannot find a solution in the documentation or forum examples.

    Comment


    • #3
      Super helpful ideas! Thank you Andrew! This gives me a way forward. Much appreciated.

      Comment


      • #4
        One more thing: You can label the studies to eliminate underscores in their names.

        Code:
        webuse metaesbin, clear
        meta esize tdead tsurv cdead csurv
        rename _meta_* *
        mkmat es - studysize, mat(meta) rownames(study) roweq(study)
        collect clear
        collect create metares
        collect get res= meta, name(metares)
        
        *OUTPUT RESULTS (STUDIES IN COLUMNS)
        collect style cell, nformat(%5.4f)
        collect style cell colname[studysize], nformat(%5.0f)
        collect levelsof rowname
        foreach name in `s(levels)'{
            collect label levels rowname `name' "`=subinstr("`name'", "_", " ", .)'", modify
        }
        collect layout (colname) (rowname)
        
        *OUTPUT RESULTS (STUDIES IN ROWS)
        collect style header colname, level(value)
        collect layout (rowname) (colname)
        Res.:

        Code:
        . collect layout (colname) (rowname)
        
        Collection: metares
              Rows: colname
           Columns: rowname
           Table 1: 5 x 4
        
        -----------------------------------------------------------------------
                                              | Study 1 Study 2 Study 3 Study 4
        --------------------------------------+--------------------------------
        Log odds-ratio                        | -0.6002  0.3509  0.7776 -2.5665
        Std. err. for log odds-ratio          |  0.7545  1.4596  0.4124  1.0568
        95% lower CI limit for log odds-ratio | -2.0791 -2.5099 -0.0306 -4.6379
        95% upper CI limit for log odds-ratio |  0.8786  3.2117  1.5859 -0.4952
        Sample size per study                 |     676     712     720     722
        -----------------------------------------------------------------------
        
        . 
        . *OUTPUT RESULTS (STUDIES IN ROWS)
        . collect style header colname, level(value)
        
        . collect layout (rowname) (colname)
        
        Collection: metares
              Rows: rowname
           Columns: colname
           Table 1: 4 x 5
        
        --------------------------------------------------
                |      es     se     cil     ciu studysize
        --------+-----------------------------------------
        Study 1 | -0.6002 0.7545 -2.0791  0.8786       676
        Study 2 |  0.3509 1.4596 -2.5099  3.2117       712
        Study 3 |  0.7776 0.4124 -0.0306  1.5859       720
        Study 4 | -2.5665 1.0568 -4.6379 -0.4952       722
        --------------------------------------------------

        Comment


        • #5
          This is a really helpful thread!
          I am hoping to be able to use -collect- to get the meta-analytic heterogeneity summaries out into a table also. However, I'm having trouble figuring out how to use -collect- to get there.

          Here's an example of my data:
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str33 study str36 tablenumstrat float(log_effect log_lowerbound log_upperbound)
          "2v9v Wen 2025"           "1.44.2 (Females 15-25 years)"          -2.521123  -3.538213  -1.504033
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
          "2v9v Wen 2025"           "1.45.2 (Females 15-25 years)"          -3.021746  -3.917773 -2.1257195
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
          "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
          "2v9v Wen 2025"           "1.5.2 (Females 15-25 years)"          -2.1896148  -3.649576  -.7296537
          "4v Wen 2024"             "1.4.3 (Females 25 years or older)"    -1.6778467  -4.875035   1.519342
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
          "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
          "2v VIVIANE 2014-INT"     "1.4.3 (Females 25 years or older)"    -.04667071  -.3113491  .21800767
          "4v FUTURE III 2009-INT"  "1.4.3 (Females 25 years or older)"     .19373766 -.17130785   .5587832
          "2v CVT 2011-CRI"         "1.5.2 (Females 15-25 years)"          -2.2867715 -4.3416953 -.23184773
          "2v Harper 2004-BRA/NA"   "1.5.2 (Females 15-25 years)"           -2.967525  -5.808503 -.12654693
          "2v Konno 2010-JPN"       "1.5.2 (Females 15-25 years)"          -1.0519797 -1.9030242  -.2009351
          "2v PATRICIA 2012-INT"    "1.5.2 (Females 15-25 years)"            -.927927 -1.1701013  -.6857526
          "4v FUTURE I/II 2010-INT" "1.5.2 (Females 15-25 years)"           -.6969835  -.8701928 -.52377427
          "2v CVT 2011-CRI"         "1.44.2 (Females 15-25 years)"          -.6734577  -.8626977  -.4842177
          "2v Harper 2004-BRA/NA"   "1.44.2 (Females 15-25 years)"          -3.788446  -6.590312    -.98658
          "2v Konno 2010-JPN"       "1.44.2 (Females 15-25 years)"         -3.8501475   -6.64819 -1.0521051
          "2v PATRICIA 2012-INT"    "1.44.2 (Females 15-25 years)"         -2.6362784  -3.018469  -2.254088
          "2v CVT 2011-CRI"         "1.45.2 (Females 15-25 years)"          -.7405763  -.8904957   -.590657
          "2v Harper 2004-BRA/NA"   "1.45.2 (Females 15-25 years)"         -2.0971081 -3.1316204 -1.0625958
          "2v Konno 2010-JPN"       "1.45.2 (Females 15-25 years)"          -3.722481  -6.524836  -.9201256
          "2v PATRICIA 2012-INT"    "1.45.2 (Females 15-25 years)"          -2.683551 -2.9839315 -2.3831706
          "2v9v KENSHE 2021-KEN"    "1.45.2 (Females 15-25 years)"          -.9834678  -1.276322  -.6906135
          end
          I then meta-set the data:
          Code:
          meta set log_effect log_lowerbound log_upperbound, civarlevel(95) random(dlaird) studylabel(study)
          And then run -meta summarize-:
          Code:
          meta summarize, subgroup(tablenumstrat)
          At the end of the meta summarize output there is a heterogeneity summary. I really would like to output this table to, for example, Excel:

          Click image for larger version

Name:	heterogeneity_summary.png
Views:	1
Size:	54.9 KB
ID:	1785855


          However, I don't think any of these heterogeneity values, nor the thetas per subgroup, are stored in post-estimation tables. I can't figure out how to run -table collect- to get either the thetas for each subgroup analysis, or the heterogeneity values in the summary at the end. Has someone else sorted this out already? If so, I would be deeply grateful for your advice.

          Comment


          • #6
            Here's how I'd do it:

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input str33 study str36 tablenumstrat float(log_effect log_lowerbound log_upperbound)
            "2v9v Wen 2025"           "1.44.2 (Females 15-25 years)"          -2.521123  -3.538213  -1.504033
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
            "2v9v Wen 2025"           "1.45.2 (Females 15-25 years)"          -3.021746  -3.917773 -2.1257195
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
            "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
            "2v9v Wen 2025"           "1.5.2 (Females 15-25 years)"          -2.1896148  -3.649576  -.7296537
            "4v Wen 2024"             "1.4.3 (Females 25 years or older)"    -1.6778467  -4.875035   1.519342
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
            "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
            "2v VIVIANE 2014-INT"     "1.4.3 (Females 25 years or older)"    -.04667071  -.3113491  .21800767
            "4v FUTURE III 2009-INT"  "1.4.3 (Females 25 years or older)"     .19373766 -.17130785   .5587832
            "2v CVT 2011-CRI"         "1.5.2 (Females 15-25 years)"          -2.2867715 -4.3416953 -.23184773
            "2v Harper 2004-BRA/NA"   "1.5.2 (Females 15-25 years)"           -2.967525  -5.808503 -.12654693
            "2v Konno 2010-JPN"       "1.5.2 (Females 15-25 years)"          -1.0519797 -1.9030242  -.2009351
            "2v PATRICIA 2012-INT"    "1.5.2 (Females 15-25 years)"            -.927927 -1.1701013  -.6857526
            "4v FUTURE I/II 2010-INT" "1.5.2 (Females 15-25 years)"           -.6969835  -.8701928 -.52377427
            "2v CVT 2011-CRI"         "1.44.2 (Females 15-25 years)"          -.6734577  -.8626977  -.4842177
            "2v Harper 2004-BRA/NA"   "1.44.2 (Females 15-25 years)"          -3.788446  -6.590312    -.98658
            "2v Konno 2010-JPN"       "1.44.2 (Females 15-25 years)"         -3.8501475   -6.64819 -1.0521051
            "2v PATRICIA 2012-INT"    "1.44.2 (Females 15-25 years)"         -2.6362784  -3.018469  -2.254088
            "2v CVT 2011-CRI"         "1.45.2 (Females 15-25 years)"          -.7405763  -.8904957   -.590657
            "2v Harper 2004-BRA/NA"   "1.45.2 (Females 15-25 years)"         -2.0971081 -3.1316204 -1.0625958
            "2v Konno 2010-JPN"       "1.45.2 (Females 15-25 years)"          -3.722481  -6.524836  -.9201256
            "2v PATRICIA 2012-INT"    "1.45.2 (Females 15-25 years)"          -2.683551 -2.9839315 -2.3831706
            "2v9v KENSHE 2021-KEN"    "1.45.2 (Females 15-25 years)"          -.9834678  -1.276322  -.6906135
            end
            
            meta set log_effect log_lowerbound log_upperbound, civarlevel(95) random(dlaird) studylabel(study)
            meta summarize, subgroup(tablenumstrat)
            
            collect clear
            collect create metares
            collect get main= r(esgroup), name(metares)
            collect style cell, nformat(%5.2f)
            collect style cell colname[P>Q tau2], nformat(%5.3f)
            collect style cell colname[df], nformat(%5.0f)
            collect style autolevels colname df Q P>Q tau2 I2 H2
            preserve
            contract `r(subgroupvars)'
            collect levelsof rowname
            local i 0
            local lastrow = word("`s(levels)'", -1)
            foreach name in `s(levels)'{
                local ++i
                collect label levels rowname `name' "`=`r(subgroupvars)'[`i']'", modify
            }
            restore
            collect label levels rowname `lastrow' "Overall", modify
            collect notes "Test of group differences: Q_b = chi2(`=string(`=r(df_Q_b)', "%3.0f")') = `:di %5.2f `=r(Q_b)''          Prob > Q_b = `:di %4.3f `=r(p_Q_b)''"
            collect title "Heterogeneity summary"
            collect layout (rowname) (colname)
            collect export mytable, as(xlsx) replace
            Res.:
            Click image for larger version

Name:	Screenshot 2026-04-24 022924.png
Views:	1
Size:	76.2 KB
ID:	1785857

            Last edited by Andrew Musau; 23 Apr 2026, 18:34.

            Comment


            • #7
              Andrew, you are a lifesaver. Thank you so much for this!!

              Comment


              • #8
                Looking at #5, towards the end - you asked about extracting the thetas. You may have already figured this out using the same approach. These are also saved in a matrix in r(), so you need minimal changes to the code in #6.

                Code:
                * Example generated by -dataex-. For more info, type help dataex
                clear
                input str33 study str36 tablenumstrat float(log_effect log_lowerbound log_upperbound)
                "2v9v Wen 2025"           "1.44.2 (Females 15-25 years)"          -2.521123  -3.538213  -1.504033
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
                "2v9v Wen 2025"           "1.45.2 (Females 15-25 years)"          -3.021746  -3.917773 -2.1257195
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
                "2v9v Kreimer 2025"       "1.45.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
                "2v9v Wen 2025"           "1.5.2 (Females 15-25 years)"          -2.1896148  -3.649576  -.7296537
                "4v Wen 2024"             "1.4.3 (Females 25 years or older)"    -1.6778467  -4.875035   1.519342
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -5.012039  -6.980327 -3.0437515
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.62296 -4.6196485 -2.6262715
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -4.326323  -5.723746 -2.9288995
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.900614  -5.046694 -2.7545335
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.2881203   -5.42929   -3.14695
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"    -3.4409 -4.1963606   -2.68544
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"   -3.77913  -4.667819   -2.89044
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -3.9967575   -4.98779 -3.0057254
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.729285  -5.136935 -2.3216352
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.735633  -5.143285 -2.3279808
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)"  -3.718698  -5.126344 -2.3110516
                "2v9v Kreimer 2025"       "1.43.1 (Females 14 years or younger)" -4.4187517  -6.394152  -2.443352
                "2v VIVIANE 2014-INT"     "1.4.3 (Females 25 years or older)"    -.04667071  -.3113491  .21800767
                "4v FUTURE III 2009-INT"  "1.4.3 (Females 25 years or older)"     .19373766 -.17130785   .5587832
                "2v CVT 2011-CRI"         "1.5.2 (Females 15-25 years)"          -2.2867715 -4.3416953 -.23184773
                "2v Harper 2004-BRA/NA"   "1.5.2 (Females 15-25 years)"           -2.967525  -5.808503 -.12654693
                "2v Konno 2010-JPN"       "1.5.2 (Females 15-25 years)"          -1.0519797 -1.9030242  -.2009351
                "2v PATRICIA 2012-INT"    "1.5.2 (Females 15-25 years)"            -.927927 -1.1701013  -.6857526
                "4v FUTURE I/II 2010-INT" "1.5.2 (Females 15-25 years)"           -.6969835  -.8701928 -.52377427
                "2v CVT 2011-CRI"         "1.44.2 (Females 15-25 years)"          -.6734577  -.8626977  -.4842177
                "2v Harper 2004-BRA/NA"   "1.44.2 (Females 15-25 years)"          -3.788446  -6.590312    -.98658
                "2v Konno 2010-JPN"       "1.44.2 (Females 15-25 years)"         -3.8501475   -6.64819 -1.0521051
                "2v PATRICIA 2012-INT"    "1.44.2 (Females 15-25 years)"         -2.6362784  -3.018469  -2.254088
                "2v CVT 2011-CRI"         "1.45.2 (Females 15-25 years)"          -.7405763  -.8904957   -.590657
                "2v Harper 2004-BRA/NA"   "1.45.2 (Females 15-25 years)"         -2.0971081 -3.1316204 -1.0625958
                "2v Konno 2010-JPN"       "1.45.2 (Females 15-25 years)"          -3.722481  -6.524836  -.9201256
                "2v PATRICIA 2012-INT"    "1.45.2 (Females 15-25 years)"          -2.683551 -2.9839315 -2.3831706
                "2v9v KENSHE 2021-KEN"    "1.45.2 (Females 15-25 years)"          -.9834678  -1.276322  -.6906135
                end
                
                meta set log_effect log_lowerbound log_upperbound, civarlevel(95) random(dlaird) studylabel(study)
                meta summarize, subgroup(tablenumstrat)
                
                collect clear
                collect create metares
                collect get main= r(hetgroup), name(metares)
                collect style cell colname, nformat(%5.3f)
                collect style autolevels colname theta se ci_lb ci_ub
                preserve
                contract `r(subgroupvars)'
                collect levelsof rowname
                local i 0
                local lastrow = word("`s(levels)'", -1)
                foreach name in `s(levels)'{
                    local ++i
                    collect label levels rowname `name' "`=`r(subgroupvars)'[`i']'", modify
                }
                restore
                collect label levels rowname `lastrow' "Overall", modify
                collect title "Subgroup meta-analysis summary"
                collect layout (rowname) (colname)
                collect export mytable, as(xlsx) replace
                Res.:

                Code:
                . collect layout (rowname) (colname)
                
                Collection: metares
                      Rows: rowname
                   Columns: colname
                   Table 1: 7 x 4
                
                Subgroup meta-analysis summary
                -----------------------------------------------------------------
                                                     |  theta    se  ci_lb  ci_ub
                -------------------------------------+---------------------------
                1.4.3 (Females 25 years or older)    |  0.033 0.121 -0.204  0.269
                1.43.1 (Females 14 years or younger) | -3.849 0.169 -4.181 -3.518
                1.44.2 (Females 15-25 years)         | -2.392 0.698 -3.759 -1.024
                1.45.1 (Females 14 years or younger) | -3.849 0.169 -4.181 -3.518
                1.45.2 (Females 15-25 years)         | -1.985 0.459 -2.885 -1.085
                1.5.2 (Females 15-25 years)          | -0.956 0.164 -1.277 -0.634
                Overall                              | -2.891 0.198 -3.279 -2.503
                -----------------------------------------------------------------

                Comment


                • #9
                  Thank you so much Andrew. In fact I was not able to figure this out on my own--for me, it was a little counterintuitive to have -hetgroup- associated with the thetas and -esgroup- associated with the heterogeneity estimates! But this makes sense and I am really grateful for your code, it helps a lot. Thank you!

                  Comment

                  Working...
                  X