Announcement

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

  • Outreg2 only showing one result of by regression.

    Hi! I am a very early beginner in Stata so I apologise in advance for any lack of info in this topic.
    Basically I need a word output for the following:
    by ID, sort : xtreg CostodelCapitalediRischioC SPGlobalESGSP_ESG BetaBETA ReturnonAssetROA ReturnonEquityROE MarkettoBookRatioMTB TotalAssetsSIZE FinancialLeverageLEV, fe
    outreg2 using myfile.doc, replace label
    ID was generated as follows: encode Indice, generate(ID) and it contains two values (FTSE and NSDQ), but unfortunately when I run the outreg command the word file only contains the results for one regression.
    How can I solve this? Sorry if the question is silly, but I am a complete novice
    Thank you!

  • #2
    outreg2 is from SSC (FAQ Advice #12). The following is not tested and may contain errors and typos.

    Code:
    levelsof ID, local(IDS)
    local estimates
    foreach ID of local IDS{
        xtreg CostodelCapitalediRischioC SPGlobalESGSP_ESG BetaBETA ReturnonAssetROA ReturnonEquityROE MarkettoBookRatioMTB TotalAssetsSIZE FinancialLeverageLEV if ID ==`ID', fe
        local estimates `estimates' est`ID'
    }
    outreg2 [`estimates'] using myfile.doc, replace label

    Comment


    • #3
      Thanks for the reply.
      When I run the code i get the following error: variable _est_est1 not found. Any suggestions?
      The regression result are displayed, but there is no word file.

      Comment


      • #4
        Sorry, I forgot to store the estimates.

        Code:
        levelsof ID, local(IDS)
        estimates clear
        local estimates
        foreach ID of local IDS{
            xtreg CostodelCapitalediRischioC SPGlobalESGSP_ESG BetaBETA ReturnonAssetROA ReturnonEquityROE MarkettoBookRatioMTB TotalAssetsSIZE FinancialLeverageLEV if ID ==`ID', fe
            est sto est`ID'
            local estimates `estimates' est`ID'
        }
        outreg2 [`estimates'] using myfile.doc, replace label

        Comment


        • #5
          Thank you so much it worked

          Comment


          • #6
            I am working with xtable and I would like to export the output with outreg2, maybe could you help me who the code work?, I tried but I do not know how to use outreg2 with matrix(r(xtable)), thanks in advance

            Comment

            Working...
            X