Hello Statalists,
I am wondering if there is any way to save -tabulate var1 var2, nofreq row- output as a matrix?
In this case, the cell values in the matrix are the row percentages instead of frequency.
And I would like to have the figures with two digits following the decimal point and no total values included in the matrix.
For example,
. tab var1 var2, row nofreq
var2
var1 1 2 3 4 5 Total
1 48.83 13.93 5.30 6.66 25.28 100.00
2 42.02 16.26 5.83 9.51 26.38 100.00
3 37.57 14.02 8.09 10.40 29.91 100.00
4 41.48 15.31 5.56 11.36 26.30 100.00
5 32.68 15.39 6.75 13.56 31.63 100.00
Total 39.08 14.93 6.39 10.95 28.66 100.00
The matrix I am expecting:
. mat list mat1
mat1[5,5]
var11 var12 var13 var14 var15
var21 .49 .14 .05 .07 .25
var22 .42 .16 .06 .10 .26
var23 .39 .14 .08 .10 .30
var24 .41 .15 .06 .11 .26
var25 .33 .15 .07 .14 .32
I have been working on this issue (and also searching for solution) for days and cannot figure out.
This is my first time to post. If I posted in the wrong place or got the format wrong, please let me know, I would like to edit it.
Thank you very much in advance.
I am wondering if there is any way to save -tabulate var1 var2, nofreq row- output as a matrix?
In this case, the cell values in the matrix are the row percentages instead of frequency.
And I would like to have the figures with two digits following the decimal point and no total values included in the matrix.
For example,
. tab var1 var2, row nofreq
var2
var1 1 2 3 4 5 Total
1 48.83 13.93 5.30 6.66 25.28 100.00
2 42.02 16.26 5.83 9.51 26.38 100.00
3 37.57 14.02 8.09 10.40 29.91 100.00
4 41.48 15.31 5.56 11.36 26.30 100.00
5 32.68 15.39 6.75 13.56 31.63 100.00
Total 39.08 14.93 6.39 10.95 28.66 100.00
The matrix I am expecting:
. mat list mat1
mat1[5,5]
var11 var12 var13 var14 var15
var21 .49 .14 .05 .07 .25
var22 .42 .16 .06 .10 .26
var23 .39 .14 .08 .10 .30
var24 .41 .15 .06 .11 .26
var25 .33 .15 .07 .14 .32
I have been working on this issue (and also searching for solution) for days and cannot figure out.
This is my first time to post. If I posted in the wrong place or got the format wrong, please let me know, I would like to edit it.
Thank you very much in advance.
Comment