Hi all,

Not sure if I've describe the problem properly in the title, but I've been trying to learn the syntax of the new table suite of commands and am running into a problem with rendering a table where I want to show the factor-variable percents both weighted and unweighted but where the different versions of the statistic are rendered across columns rather than across rows. I thought I understood the table (rowvars) (colvars) syntax, but it is producing surprise results for me and I'm wondering if anyone can help me understand how to get to the display I'm hoping for. (Note that the content of these tables is a little non-sensical, I just reached for the easiest data example I could find. Please trust that in my true use case I have a factor variable that occurs with different probability within the categories of the column variables.)

Here's some data:

sysuse census, clear

Code:
gen random_category = runiformint(1, 5) 

table (region state2) (var) [fw=pop], ///
    stat(fvpercent random_category) stat(fvrawpercent random_category)
Which produces:

Code:
----------------------------------------------------------------------------------------
                                           |                random_category             
                                           |       1        2        3        4        5
-------------------------------------------+--------------------------------------------
Census region                              |                                            
  NE                                       |                                            
    Two-letter state abbreviation          |                                            
      CT                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00   100.00     0.00
        Unweighted factor variable percent |    0.00     0.00     0.00   100.00     0.00
      MA                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00   100.00     0.00
        Unweighted factor variable percent |    0.00     0.00     0.00   100.00     0.00
      ME                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00   100.00     0.00
        Unweighted factor variable percent |    0.00     0.00     0.00   100.00     0.00
      NH                                   |                                            
        Factor variable percent            |    0.00     0.00   100.00     0.00     0.00
        Unweighted factor variable percent |    0.00     0.00   100.00     0.00     0.00
      NJ                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00     0.00   100.00
        Unweighted factor variable percent |    0.00     0.00     0.00     0.00   100.00
      NY                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00   100.00     0.00
        Unweighted factor variable percent |    0.00     0.00     0.00   100.00     0.00
      PA                                   |                                            
        Factor variable percent            |    0.00   100.00     0.00     0.00     0.00
        Unweighted factor variable percent |    0.00   100.00     0.00     0.00     0.00
      RI                                   |                                            
        Factor variable percent            |    0.00     0.00     0.00   100.00     0.00
        Unweighted factor variable percent |    0.00     0.00     0.00   100.00     0.00
      VT                                   |                                            
        Factor variable percent            |    0.00   100.00     0.00     0.00     0.00
        Unweighted factor variable percent |    0.00   100.00     0.00     0.00     0.00
      Total                                |                                            
        Factor variable percent            |    0.00    25.19     1.87    57.95    14.99
        Unweighted factor variable percent |    0.00    22.22    11.11    55.56    11.11
When ideally it would be:

Code:
-------------------------------------------------------------------------------------------------------------------------------------------
                                           |        random_category (weighted)               |           random_category   (unweighted)
                                           |       1        2        3        4        5     |    1        2        3        4        5
-------------------------------------------+-------------------------------------------------+---------------------------------------------
Census region                              |                                                 |
  NE                                       |                                                 |
    Two-letter state abbreviation          |                                                 |
      CT                                   |  0.00     0.00     0.00   100.00     0.00       |    0.00     0.00     0.00   100.00     0.00
I've tried redoing this with percent and rawpercent combined with the across suboption, but it produces the same thing, so I'm just a little stumped. Any help would be greatly appreciate.