Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • printing zero in crosstabulations in tables (plus why is zero not a valid search term?)

    Is there any way to print a zero when there are no cases in a crosstabulation in the tables command? My collaborators think having the 2 zeros in the appropriate cells in a table with 42 cells would be more informative than the blank spaces.

    Also, why is the word "zero" not a valid search term in the forum interface? Searching only on the word "zero" gets an error message that the search is not restrictive enough. Searching "zero frequency" returns results with the word "frequency" but not the word zero. Even restricting to title search only generates a very large number of inquiries about frequencies that have nothing to do with zero.

  • #2
    This is not possible with the available -tabulate- and -table- commands and I have requested that it be added to -table-.

    One-way frequency tables are possible using -fre- with the include command. Or else, you will have to produce tables using other methods.

    Comment


    • #3
      tabulate with two-way tables shows zero by default. Indeed, I am not sure how to get rid of the zeros.

      Code:
      . sysuse auto, clear
      (1978 automobile data)
      
      . tab rep78 foreign
      
          Repair |
          record |      Car origin
            1978 |  Domestic    Foreign |     Total
      -----------+----------------------+----------
               1 |         2          0 |         2 
               2 |         8          0 |         8 
               3 |        27          3 |        30 
               4 |         9          9 |        18 
               5 |         2          9 |        11 
      -----------+----------------------+----------
           Total |        48         21 |        69

      Comment


      • #4
        I guess Leonardo and Nick are talking about different things:

        Leonardo talks about a variable where we humans know there is an outcome category that no respondent has chosen. For example, if for the variable rep78 in Nick's example there was a possible category 6 (super-duper excellent) and in this dataset no car fell in that very exclusive category. In that case Stata does not now there is this potential extra category and it will not show this. What Ben Jann did with fre is to allow you to make an assumption: if there is a value label for the value 6, but no such value in the data, then you can assume that 6 is such a "non-chosen potential value". I can see applications where such an option could be very useful.

        Nick is talking about a the case where a combination of values does not occur. For example there are cars in rep78 category 1 in the data, but there are no foreign cars in rep78 category 1. In that case the 0s are displayed.

        I will give you a third interpretation of you question: The new table command does not display the 0s even in Nick's case.

        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . table (rep78) (foreign)
        
        ------------------------------------------------
                           |          Car origin        
                           |  Domestic   Foreign   Total
        -------------------+----------------------------
        Repair record 1978 |                            
          1                |         2                 2
          2                |         8                 8
          3                |        27         3      30
          4                |         9         9      18
          5                |         2         9      11
          Total            |        48        21      69
        ------------------------------------------------
        I don't know how to change that. table is still a new command, and a fairly complicated one, and I had no time to really get to know it.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Maarten Buis is absolutely correct, but the question #1 and my answer #3 focus only on cross-tabulations. I guess one-way tables are degenerate cases of cross-tabulation, but I didn't address them in my answer.

          tabcount as discussed in 2003 https://www.stata-journal.com/articl...article=pr0011 is one contribution here, but Ben Jann's fre from SSC is on the whole more versatile.

          groups as discussed principally in 2017 https://www.stata-journal.com/articl...article=st0496 offers a different approach, but is not at all, I think, what Pamela Oliver is seeking.

          Comment

          Working...
          X