Announcement

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

  • Question about missing and percentages

    Hello! I have a simple question but I have found it counterintuitive so far and am hoping that this is just a simple/quick solution.

    When I use
    Code:
    tab var1 var2, m col nofreq
    I get a table with percentages by column, missings show up, and there are no frequencies. This is exactly what I want except for one thing: the missings, I presume because I am including them in the line of code to show in the table, are included as part of the percentages.

    What I am hoping is possible is to get missings to show up in the table, but not have them be included in the percentage calculation, such as if I wrote
    Code:
    tab var1 var2, col nofreq
    (which then does not take missing as part of the calculation but also does not show missing in the table!)

    If this is possible, please advise. Thank you much!

  • #2
    Hi Anne,

    Stata is being consistent. If the missing class appears on the table, then the relative frequencies reflect that. If you ask Stata to not display the missing observations, then no missing class will be displayed on the absolute or relative frequencies. I usually deal with this data with a prior information: var1 had x many missing observations. Out of those that were not missing (thus, the total N observations is now smaller: N-missing), x (x%) belongs to class 1, y (y%) to class y and so on.

    Comment


    • #3
      Thanks, Igor. Yes, it certainly is being consistent!

      The simplest way I could think of fixing it was by just running the code that will get me nonmiss percentages:
      Code:
      tab var1 var2, col nofreq
      And then immediately after, run
      Code:
      tab var1 var2, m
      And then just add in the missing row and column manually when I transfer the first table to Word. I'm sure many here would shudder at the thought of that, though.

      Comment


      • #4
        groups from the Stata Journal can do this for you.

        I will post an example later.

        Comment


        • #5
          Thank you kindly as always, Nick Cox .

          Comment


          • #6
            Here is an example:

            Code:
            . sysuse auto, clear
            (1978 Automobile Data)
            
            . groups rep78, missing show(f v)
            
              +-------------------------+
              | rep78   Freq.   % Valid |
              |-------------------------|
              |     1       2      2.90 |
              |     2       8     11.59 |
              |     3      30     43.48 |
              |     4      18     26.09 |
              |     5      11     15.94 |
              |-------------------------|
              |     .       5         . |
              +-------------------------+
            
            . groups rep78, missing show(f v V)
            
              +----------------------------------+
              | rep78   Freq.   % Valid   % V.<= |
              |----------------------------------|
              |     1       2      2.90     2.90 |
              |     2       8     11.59    14.49 |
              |     3      30     43.48    57.97 |
              |     4      18     26.09    84.06 |
              |     5      11     15.94   100.00 |
              |----------------------------------|
              |     .       5         .        . |
              +----------------------------------+
            
            . groups rep78, missing show(f v V) sep(0)
            
              +----------------------------------+
              | rep78   Freq.   % Valid   % V.<= |
              |----------------------------------|
              |     1       2      2.90     2.90 |
              |     2       8     11.59    14.49 |
              |     3      30     43.48    57.97 |
              |     4      18     26.09    84.06 |
              |     5      11     15.94   100.00 |
              |     .       5         .        . |
              +----------------------------------+
            https://www.statalist.org/forums/for...updated-on-ssc gives a brief introduction. The software may be downloaded from SSC or the Stata Journal.

            Code:
            ssc install groups
            https://www.stata-journal.com/articl...article=st0496 requires purchase or subscription access until Q3 2020.

            See also Ben Jann's fre from SSC.

            Code:
            ssc describe fre

            Comment


            • #7
              Thank you very much, Nick. I will also look at -fre- as well.

              Comment

              Working...
              X