Loading and storing data to and from Stata and Mata


mkmat varlist, matrix(M)    /creates Stata matrix M/
mata{
M=st_matrix(“M”)        /loads matrix M to Mata/

st_matrix(“M”, M)
}
svmat M    /loads matrix M back to Stata/

OR

mata{
M=st_data(.,.)   /reads current Stata data as matrix M in Mata/

st_store(.,1..cols(M), M)    /loads matrix M back to Stata/
}

Leave a Reply