Announcement

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

  • export spearman results into excel file

    hi,

    I would like to export the result of "spearman, print(.05) star(.01)" command.
    I succeed with single "spearman" command, but I don't find the way to export, with "print(.05) star(.01)" options.

    I do
    spearman, print(.05) star(.01)
    putexcel set "export.xlsx"
    putexcel A1=matrix (r(Rho))

    Thanks in advance for your help.




  • #2
    Code:
    ssc install estout, replace
    Code:
    webuse states2, clear
    spearman mrgrate divorce_rate medage, print(.05) star(.01)
    
    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 . using myfile.csv, replace b(3) unstack ///
    nonum nomtitle not noobs label compress ///
    eqlabels((1) (2) (3), lhs("Variables")) starlevels(* 0.01)
    restore
    Res.:

    Code:
    . spearman mrgrate divorce_rate medage, print(.05) star(.01)
    (obs=50)
    
                 |  mrgrate divorc~e   medage
    -------------+---------------------------
         mrgrate |   1.0000 
    divorce_rate |   0.6933*  1.0000 
          medage |  -0.4869*           1.0000 
    
    
    . esttab ., replace b(3) unstack ///
    > nonum nomtitle not noobs label compress ///
    > eqlabels((1) (2) (3), lhs("Variables")) starlevels(* 0.01)
    
    -------------------------------------------------
    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.01
    Use the -substitute()- option of estout to exclude coefficients less than .05.

    Code:
    help estout

    Comment

    Working...
    X