program define matrixlisthtml
args matrixname precision
*mat li `matrixname'
local rownames: rown `matrixname'
local colnames: coln `matrixname'

di "<tr><th></th>"
foreach mycol in `colnames' {
 di "<th>" as text "`mycol'" "</th>"
}
di "</tr>"

local rowindex=1

forvalues rowptr=1/`=rowsof(`matrixname')' {
	local rowname: word `rowindex' of `rownames'
	di "<tr><th>" "`rowname'" "</th>" 
	forvalues colptr=1/`=colsof(`matrixname')' {	
		di "<td>" `precision' `matrixname'[`rowptr', `colptr'] "</td>"
	}
	di "</tr>"
	local ++rowindex
}
end
