Announcement

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

  • Exporting iterative Metaan results to excel

    I developed an iterative loop to calculate Metaan for a total of 39 studies. I have been trying to export Metaan results (scalars) to excel sheet using and modifying the following code. I am only able to export the very last result and not all the results in the same column. Is there a way I can modify the code to get the result I want?


    putexcel set testing.xls, modify

    forvalues i = 1/40 {
    display `i'
    metaan ES SE if Study <`i', dl
    return list

    putexcel (B2) = rscalars
    }

  • #2
    Welcome to Statalist.

    You are putting every set of output, one at a time, into the same place in your workbook - rows 2-15 of column B.

    Perhaps the following will start you in a useful direction. My understanding is that metaan returns 14 scalars, and you want them all put into a single column which will eventually contain 40*14 results.
    Code:
    putexcel set testing.xls, modify
    local row 2
    forvalues i = 1/40 {
        display `i'
        metaan ES SE if Study <`i', dl
        return list
        putexcel (B`row') = rscalars
        local row = `row'+14
    }
    Last edited by William Lisowski; 09 Feb 2019, 07:33.

    Comment


    • #3
      Hi Juhi,

      William's code should do the trick. You may want to think about which scalars you really need, rather than saving them all.

      However, your code suggests you are trying to perform a cumulative meta-analysis, whereby studies are added one-at-a-time and you can see how the pooled effect and heterogeneity evolve.
      ​​​​​​​If this is the case, the Stata command admetan can do this for you. It has the ability to store all the cumulative results in a new Stata dataset for further analysis. If you really need it in Excel, you could then simply transfer the entire new dataset into Excel in one go.

      Here is some possible code, based on your own code above:
      Code:
      ssc install admetan
      admetan ES SE, cumulative random saving(myfile.dta)
      use myfile.dta, clear
      list
      I hope this is of use to you.

      Best wishes,

      David.

      Comment


      • #4
        Thank you William and David. I was looking for results obtained from 'admetan'. This was very helpful.

        Best,
        Juhi.

        Comment

        Working...
        X