I want to create a 3x3 crosstab and output it to latex. I've tried this with a combination of esttab, estout and it is not possible, as I need counts, statistics, test statistics, asterix and various other calculations involving rowsums and colsums in the table.
On advice from the forum here, I'm iterating through a number of row and column categories, calling the `table' command and populating a matrix (and an annotation matrix). I'm ending up with something like this:
matrix res = J(2,2,.)
matrix res[1,1] = round(0.29 * 100,.01)
matrix res[2,1] = 10514
matrix res[1,2] = round(0.5566 * 100,.01)
matrix res[2,2] = 18895
matrix rownames res = Percentage Observations
frmttable, tex plain fragment statmat(res) replace ///
sdec(2)
I need (i) the first row to have two trailing zeros and (ii) the second row to be round to the nearest integer. I've refactored the underlying code in frmttable so that if I omit sdec(2), no formatting with be applied to the matrix when it's output to latex. However, the issue with trailing zeros is not resolved.
I've tried to change the cell value to a string, format it and return it with the `real' command, but it still strips off the trailing zeros. The sdec command can accept an array of decimal places for each column, but not an array of decimal places for each row.
Any idea how I can achieve this?
On advice from the forum here, I'm iterating through a number of row and column categories, calling the `table' command and populating a matrix (and an annotation matrix). I'm ending up with something like this:
matrix res = J(2,2,.)
matrix res[1,1] = round(0.29 * 100,.01)
matrix res[2,1] = 10514
matrix res[1,2] = round(0.5566 * 100,.01)
matrix res[2,2] = 18895
matrix rownames res = Percentage Observations
frmttable, tex plain fragment statmat(res) replace ///
sdec(2)
I need (i) the first row to have two trailing zeros and (ii) the second row to be round to the nearest integer. I've refactored the underlying code in frmttable so that if I omit sdec(2), no formatting with be applied to the matrix when it's output to latex. However, the issue with trailing zeros is not resolved.
I've tried to change the cell value to a string, format it and return it with the `real' command, but it still strips off the trailing zeros. The sdec command can accept an array of decimal places for each column, but not an array of decimal places for each row.
Any idea how I can achieve this?
Comment