Announcement

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

  • Export mdesc table to Excel

    I am wondering if there is way to export (not copy paste) and mdesc table (run on the full set of my data set's variables) to Excel.

  • #2
    This is by Nix Cox.
    Code:
    program mmdesc, rclass byable(recall)
    syntax [varlist] [if] [in]
    tempvar touse
    mark `touse' `if' `in'
    local nvars : word count `varlist' 
    tempname matrix 
    matrix `matrix' = J(`nvars', 3, .) 
    local i = 1 
    quietly foreach var of local varlist {
        count if missing(`var') & `touse' 
        matrix `matrix'[`i', 1] = r(N) 
        count if `touse'
        matrix `matrix'[`i', 2] = r(N) 
        matrix `matrix'[`i', 3] = `matrix'[`i',1] / `matrix'[`i',2] 
        local ++i  
    }
    matrix rownames `matrix' = `varlist'                     
    matrix colnames `matrix' = Missing Total Missing/Total 
    matrix list `matrix', noheader 
    return matrix table = `matrix' 
    end
    To do it,
    Code:
    putexcel set missingtable
    mmdesc x1 x2 x3
    putexcel A1 = matrix(r(table))

    Comment


    • #3
      I suppose "Nix Cox" is a reference to me and indeed I re-discovered this code at https://www.stata.com/statalist/arch.../msg01039.html

      I've not done anything to the code since it was written, but if it helps, that's naturally fine by me.

      Comment


      • #4
        Hah. Where's the spell check?

        Comment

        Working...
        X