*! version 1.0.0  13Feb2018
program define mymeanc, eclass

    version 15.1

    syntax varlist(numeric) [if] [in]
    marksample touse
    tempname b V N

    local k : word count `varlist'
    matrix `b' = J(1, `k', .)
    matrix `V' = J(`k', `k', .)

    plugin call mycalcs `varlist' if `touse' `in', `b' `V' `N'

    matrix colnames `b'  = `varlist'
    matrix colnames `V'  = `varlist'
    matrix rownames `V'  = `varlist'
    ereturn post `b' `V', esample(`touse')
    ereturn scalar   N   = `N'
    ereturn scalar df_r  = `N'-1
    ereturn display

end

program mycalcs, plugin