Announcement

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

  • Spearman correlation table export into Excel

    Hi everyone,
    I have a problem trying to export my Spearman correlation results into Excel.

    I use:
    matrix A = r(Rho)
    esttab matrix(A, fmt(%5.2f)) using "Results.csv", replace

    Using this command I have the correlation table BUT without stars (0.01) + I need only print (0.1) with 4 signs after comma but in Excel I get everything exported with 2 signs.
    Is it anyhow possible to get only the needed results exported and with the stars?***

    I find the solution only for "correlation" and not for "spearman".
    Thank you a lot in advance!

  • #2
    If you know a solution for (Pearson) correlation, then rank transform all your variables and then push the correlations for those through your solution.

    (I have no idea what the solution is, being predisposed to avoid starring results at all.)

    Comment


    • #3
      esttab/ estout is from the Stata Journal (FAQ Advice #12). Going with Nick's advice, you can do something like


      Code:
      webuse states2, clear
      spearman mrgrate divorce_rate medage
      preserve
      foreach var in mrgrate divorce_rate medage{
          egen `var's= rank(`var')
          cap lab var `var's "`: var label `var''"
          drop `var'
          rename `var's `var'    
      }
      estpost corr  mrgrate divorce_rate medage, matrix
      esttab ., b(3) unstack nonum nomtitle not noobs label ///
      compress eqlabels((1) (2) (3), lhs("Variables"))
      restore
      Res.:

      Code:
      . spearman mrgrate divorce_rate medage
      (obs=50)
      
                   |  mrgrate divorc~e   medage
      -------------+---------------------------
           mrgrate |   1.0000
      divorce_rate |   0.6933   1.0000
            medage |  -0.4869  -0.2455   1.0000
      
      
      
      . esttab ., b(3) unstack nonum nomtitle not noobs label ///
      > compress eqlabels((1) (2) (3), lhs("Variables"))
      
      -------------------------------------------------------
      Variables              (1)          (2)          (3)  
      -------------------------------------------------------
      Marriages pe~000     1.000                            
      Divorces per~000     0.693***     1.000                
      Median Age          -0.487***    -0.246        1.000  
      -------------------------------------------------------
      * p<0.05, ** p<0.01, *** p<0.001

      Comment


      • #4
        With the latest update, asdocx users can now export output from the spearman command. This update allows users to export spearman’s correlation tables directly to various formats such as Excel, Word, HTML, or LaTeX. Here one example, explore more here.

        Code:
        * Load example data
        webuse states2
        
        * export the table to MS Excel
        asdocx spearman mrgrate divorce_rate medage, save(Spearman.xlsx) star(.05) replace


        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment

        Working...
        X