Rune Lomholt
Participant
Post count: 19

This is really useful and I actually need something like this now.

This approach only seem work if using the replace option, but I am creating a report of descriptive statistics by using collect mode so I need to run the code and only append the final table in the report.

I use the following code;
asdocx tab skoleid s_3 if skoleid ~=11, rowsort

which gives me:


                             Tabulation of skoleid s_3
  0 |1                                   2                3                4 
----+-----------------------------------------------------------------------------
  1 |  skoleid                         s_3                                   
----+-----------------------------------------------------------------------------
  2 | 1                                Nej               Ja            Total 
  3 |Tåsingeskolen                      77               51              128 
  4 |                               60.156           39.844              100 
  5 |Thurø Skole                        62               25               87 
  6 |                               71.264           28.736              100 
  7 |Stokkebækskolen                    38               36               74 
  8 |                               51.351           48.649              100 
  9 |Issø-skolen                        34               25               59 
 10 |                               57.627           42.373              100 
 11 |Tved Skole                         31               27               58 
 12 |                               53.448           46.552              100 
 13 |Skårup Skole                       28               26               54 
 14 |                               51.852           48.148              100 
 15 |Rantzausminde Skole                30               14               44 
 16 |                               68.182           31.818              100 
 17 | Total                            300              204              504 
 18 |                               59.524           40.476              100 
----------------------------------------------------------------------------------

and then
flexmat droprow, row(3,5,7,9,11,13,15)
which gives me:


                             Tabulation of skoleid s_3
  0 |1                                                    2               3                       4 
----+-------------------------------------------------------------------------------------------------------------
  1 |\vline  skoleid                      \qc \hmerge_3 s_3                                         
----+-------------------------------------------------------------------------------------------------------------
  2 |\rowheader \vmerge_1                               Nej              Ja            \hline Total 
  3 |                                                60.156          39.844                     100 
  4 |                                                71.264          28.736                     100 
  5 |                                                51.351          48.649                     100 
  6 |                                                57.627          42.373                     100 
  7 |                                                53.448          46.552                     100 
  8 |                                                51.852          48.148                     100 
  9 |                                                68.182          31.818                     100 
 10 |\hline Total                                       300             204                     504 
 11 |                                                59.524          40.476                     100 
------------------------------------------------------------------------------------------------------------------

The value labels of skoleid in column 1 disappears because these are situated in the the rows that I am dropping with flexmat. Some way to resolve this?

I would also like to give names to the column header. I would like to add the total N of each category of variable skoleid before column 2.
In the final table I would like to name column 1 “skole”, column 2 “N”, column 3 “Nej”, column 4 “Ja”, and column 5 “Total”.

If you can help this would be great! Thank you so much.