Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • Jaemin Lee
    Participant
    Post count: 17

    When using tabulate with row/column sort, I find that percentages are always reported.
    Is there a way to suppress this, and report only the frequencies?

    sysuse auto
    asdocx tab rep78 foreign, rowsort colsort 
    Dr. Attaullah Shah
    Keymaster
    Post count: 106

    You can get rid of any column or row using the capability of flexmat. See this example

    * First create the full table
    asdocx tab rep78 foreign, rowsort colsort replace                            
                                    Tabulation  of rep78 foreign
      0 |1                                          2             3            4 
    ----+-----------------------------------------------------------------------------
      1 |  Repair record 1978              Car origin                            
    ----+-----------------------------------------------------------------------------
      2 | 1                                  Domestic       Foreign        Total 
      3 |3                                         27             3           30 
      4 |                                          90            10          100 
      5 |                                       56.25        14.286       43.478 
      6 |4                                          9             9           18 
      7 |                                          50            50          100 
      8 |                                       18.75        42.857       26.087 
      9 |5                                          2             9           11 
     10 |                                      18.182        81.818          100 
     11 |                                       4.167        42.857       15.942 
     12 |2                                          8             0            8 
     13 |                                         100             0          100 
     14 |                                      16.667             0       11.594 
     15 |1                                          2             0            2 
     16 |                                         100             0          100 
     17 |                                       4.167             0        2.899 
     18 | Total                                    48            21           69 
     19 |                                      69.565        30.435          100 
     20 |                                         100           100          100 
    ----------------------------------------------------------------------------------
    Click to Open File:  C:\temp\MyFile.docx
    
    * The flexmat table shows rows and columns numbers for easy identification
    ** drop the desired rows
    . flexmat droprow, row(4,5,7,8,10,11,13,14,16,17,19,20)
    
    
       
                                Tabulation of rep78 foreign
      0 |1                                                             2                 3                     4 
    ----+-------------------------------------------------------------------------------------------------------
      1 |       Repair ~1978                    Car origin                                           
    ----+-------------------------------------------------------------------------------------------------------
      2 |                                                       Domestic           Foreign                 Total 
      3 |3                                                            27                 3                    30 
      4 |4                                                             9                 9                    18 
      5 |5                                                             2                 9                    11 
      6 |2                                                             8                 0                     8 
      7 |1                                                             2                 0                     2 
      8 |       Total                                                 48                21                    69 
    ------------------------------------------------------------------------------------------------------------
    
    * Now export the results
    . asdocx export
    

     

    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.

    Dr. Attaullah Shah
    Keymaster
    Post count: 106

    Turns out that rowsort and colsort options in Stata generate frequencies, without percentages. To make the asdocx output at par with that of the Stata’s output, I have now made some changes to asdocx. Therefore, these options no longer generate percentages. See the following example

    asdocx_update
    sysuse auto, clear
    
    * using rowsort and colsort options
    asdocx tab rep78 foreign ,  rowsort colsort replace
    
                               Tabulation of rep78 foreign
      0 |1                                      2             3             4 
    ----+-----------------------------------------------------------------------------
      1 |  Repair Record 1978            Car type                             
    ----+-----------------------------------------------------------------------------
      2 | 1                              Domestic       Foreign         Total 
      3 |3                                     27             3            30 
      4 |4                                      9             9            18 
      5 |5                                      2             9            11 
      6 |2                                      8             0             8 
      7 |1                                      2             0             2 
      8 | Total                                48            21            69 
    ----------------------------------------------------------------------------------
    
    
    Dr. Attaullah Shah
    Keymaster
    Post count: 106

    @Rune Lomholt
    If you want to report just the percentages, you can use the nofreq option

    asdocx tab rep78 foreign ,  rowsort nofreq replace
      
                                Tabulation of rep78 foreign
    
      0 |1                                          2             3            4 
    ----+-----------------------------------------------------------------------------
      1 |  Repair record 1978              Car origin                            
    ----+-----------------------------------------------------------------------------
      2 | 1                                  Domestic       Foreign        Total 
      3 |3                                         90            10          100 
      4 |4                                         50            50          100 
      5 |5                                     18.182        81.818          100 
      6 |2                                        100             0          100 
      7 |1                                        100             0          100 
      8 | Total                                69.565        30.435          100 
    ----------------------------------------------------------------------------------
    
    Jaemin Lee
    Participant
    Post count: 17

    Is it possible that this part is not updated?
    I run the exactly same code and I still get percentages:

    asdocx_update
    sysuse auto, clear

    * using rowsort and colsort options
    asdocx tab rep78 foreign , rowsort colsort replace

    `

    . * using rowsort and colsort options
    . asdocx tab rep78 foreign , rowsort colsort replace

    Tabulation of rep78 foreign
    0 |1 2 3 4
    —-+—————————————————————————–
    1 | Repair Record 1978 Car type
    —-+—————————————————————————–
    2 | 1 Domestic Foreign Total
    3 |3 27 3 30
    4 | 90 10 100
    5 |4 9 9 18
    6 | 50 50 100
    7 |5 2 9 11
    8 | 18.182 81.818 100
    9 |2 8 0 8
    10 | 100 0 100
    11 |1 2 0 2
    12 | 100 0 100
    13 | Total 48 21 69
    14 | 69.565 30.435 100
    ———————————————————————————-

    Dr. Attaullah Shah
    Keymaster
    Post count: 106

    You are right. Please update it now.

    Rune Lomholt
    Participant
    Post count: 19

    Here I have another one related to the tabulate command:

    Is it possible to export statistics using asdocx tab var, title() and still show empty categories, but without treating missing values as values when calculating percentages. This is, if a particular response category has zero observations, is shown as 0 frequency, zero percentage and the appropriate cumulative percentage according to its place in the table… But missing values are still now shown as normal.

    Rune Lomholt
    Participant
    Post count: 19

    I have found this community contributed command
    ssc desc fre
    Which allows what I am looking for, when using the code fre var, all include(1 2 3 4) novalue nomissing. Looks like this:

    			
         			
    	        Freq.	Percent	Cum.
    			
    Slet ikke	0	0.00	0.00
    I lav grad	0	0.00	0.00
    Hverken/eller	1	6.25	6.25
    I nogen grad	2	12.50	18.75
    I høj grad	13	81.25	100.00
    Total	        16	100.00	          
    			
         
    			
    

    Maybe this could be supported by asdocx? Either by supporting this command or extending the capabilities of asdocx with the regular tab command?
    I now it might sounds odd wanting to report empty categories, since they do not exist in a statistical sense.
    But I use these command for making descriptive statistics reports were people who don’t know a first thing about statistics has to read frequency tables, and they always ask “why is the scale different in this item?” which is really annoying. Therfore, i prefer just to include empty categories to make it transparent.

    Thank you for reading this post!

    Eric Melse
    Participant
    Post count: 7

    I agree with Rune that an option to also ‘report’ empty categories is very usefull because it explains to the reader that such categories are present as such but not present in the then current data set.

    Best,
    Eric

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.