Announcement

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

  • dtable summary

    Hi there - for dtable, is it possible to specify non- missing values only to produce the summary table ?

    I have a two-way summary table wherein most variable has missing value, but I do not need to count of those missing value to be included in summary statistic.

    I tried to use
    :
    Code:
    dtable v1 v2 v3 , by(group,  nomissing ) sample(,  place(seplabels)) sformat("(N=%s)" frequency) nformat(%7.2f mean sd) title(Table 1. Descriptive statistics) note(Mean (Standard deviation)) export(table1.docx, replace
    Code:
    
    

    )
    but this gave me error "option by not allowed
    in option by()"



    Thanks,


  • #2
    Was not able to recreate that error. This example works fine:

    Code:
    sysuse auto, clear
    
    dtable rep78 headroom price , by(foreign,  nomissing ) sample(,  place(seplabels)) sformat("(N=%s)" frequency) nformat(%7.2f mean sd) title(Table 1. Descriptive statistics) note(Mean (Standard deviation))
    It would be great if you can provide a small sample of data using dataex that would produce the error you described.

    Comment


    • #3
      Originally posted by Ken Chui View Post
      Was not able to recreate that error. This example works fine:

      Code:
      sysuse auto, clear
      
      dtable rep78 headroom price , by(foreign, nomissing ) sample(, place(seplabels)) sformat("(N=%s)" frequency) nformat(%7.2f mean sd) title(Table 1. Descriptive statistics) note(Mean (Standard deviation))
      It would be great if you can provide a small sample of data using dataex that would produce the error you described.
      Thanks Ken for your reply

      here is the sample of my data :

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input double(hourpay hrrate lockdwon) byte(ages sex) long(industry1 full_time part_time temporary_job1) byte publicr
                       .    .    0 14 2  7 0 1 . 1
                       .    .    0 13 2 12 0 1 0 1
      6.2700000000000005  998    0 10 2  8 1 0 0 1
                       .    .    0  9 1 14 1 0 . 1
                       .    .    0 10 2 12 0 1 0 2
                       .    .    0 10 2 14 1 0 0 1
                   12.25    .    0  8 1 23 1 0 0 1
                   15.88   16    0 10 2 12 0 1 0 2
                       .    .    0 12 2 18 0 1 . 1
                   19.47    .    0  7 1 17 1 0 0 1
                       .    .    0 14 1 23 0 1 . 1
                       .    .    0  9 1  7 1 0 0 2
                       .  998    0 14 2 12 0 0 0 2
                       .    . 22.7  9 2 14 1 0 0 1
                       .    .    0 12 1  7 0 1 1 2
                    8.33    8    0 14 1 23 0 1 0 1
                       .    .  6.3 14 1 14 1 0 0 1
                       .    .  4.1 11 1  5 1 0 0 1
                       .    .    0 14 1 19 0 1 0 2
                   18.17    .    0 13 2  9 1 0 0 2
                       .    .  2.2 13 1 21 1 0 0 1
                   30.23    .    0 10 1  2 1 0 0 1
                       .    .  8.3  6 2 14 1 0 0 1
                       .    .    0 13 1 14 1 0 0 1
                    9.17 8.72 78.1 12 1  1 1 0 0 1
                    9.23  998    0 11 2  7 1 0 0 1
                       .    .    0 12 2 17 1 0 . 1
                       .    .  1.8 10 2 23 1 0 0 1
                       .    .  3.5  6 2  7 1 0 0 2
                       .    . 29.4  8 2 23 0 1 . 1
                       .    .    0  9 2 12 1 0 . 1
                       .    . 17.4 14 1  5 1 0 . 1
                   28.85    .    0 11 2  5 0 1 0 1
                       .    .    0 13 1 14 1 0 0 1
                       .    .    0 10 2 12 0 1 0 1
                       .    .    0 12 1 19 1 0 0 2
                    9.28 9.85    0 13 1  2 1 0 0 1
                       .    .    0  7 1  5 1 0 . 1
                       .    .    0 13 2 12 0 1 . 1
       8.290000000000001    .    0 10 2  7 0 1 0 2
                       .    .  2.4 13 1  5 0 1 0 1
       9.870000000000001 10.9    0  9 2  2 1 0 1 1
                       .    .    0 12 1 19 1 0 0 2
                       .    .    0 12 2 18 0 1 0 1
                       .    . 37.9 11 1  1 1 0 0 1
                    9.61  9.5    0 13 2 12 1 0 0 2
                       .    .    0  9 1 14 1 0 0 1
                       .    .    0 13 2 12 0 1 0 1
                    19.2    .    0  8 2  7 0 1 0 2
                       .    .    0 12 2 19 1 0 0 1
                       .    .    0 12 1  7 1 0 0 2
                       .    .    0 12 1 14 1 0 0 1
                       .    .    0 12 2 17 1 0 0 1
      10.290000000000001 9.55  3.3 12 2 14 0 1 0 1
                   10.11    .    0  9 2 18 1 0 0 1
                       .    .    0 12 1 23 1 0 . 1
                       .    .    0 10 1 14 1 0 0 1
                       .    .    0 11 1 10 1 0 0 1
                       .    . 34.8 11 2  7 0 1 0 2
                   21.38    .  7.5 11 1 18 1 0 0 1
                       .    .    0  7 2 23 0 1 0 1
                   13.42  998    0 10 1 12 1 0 0 1
                       .    .    0 13 2 12 1 0 0 2
      12.030000000000001    .    0  8 2 13 1 0 0 1
                       .    .    0  5 2 12 1 0 0 2
                   15.58 15.8    0  8 2 12 1 0 0 2
                       .    .    0 12 1  5 1 0 0 1
                       .    . 24.2 13 2  4 0 1 1 1
                       .    .    0 10 2 12 1 0 0 2
                       .    .  6.6  9 1  4 1 0 1 2
                       .    .    0 11 2 18 0 1 0 1
                   20.62    .    0  8 2  7 0 1 0 2
                      10    9    0 13 1 23 0 1 0 1
                       .    .    0 11 2 12 1 0 0 2
                       .    .    0  8 1 13 1 0 . 1
                       .    .    0 11 2  7 1 0 0 2
                   14.68   14    0  6 1 13 1 0 0 1
                   32.89    .    0  7 2 14 1 0 0 1
                       .    .    0 11 2  7 1 0 0 2
                       .    .    0  6 1  5 1 0 0 1
                   93.81    .    0  9 1 23 1 0 0 1
                       .    .    0 12 2 18 1 0 0 1
                       .    .    0 10 2 19 1 0 0 2
                       .    .    0  9 1 18 1 0 . 1
                       .    .    0 10 1 13 1 0 0 1
                   15.32    .    0 10 2 19 1 0 0 2
                       .    .  2.4  8 1  5 1 0 0 1
                       .    .    0  9 1 12 1 0 0 2
                       .    .    0  9 2  7 0 1 0 2
                       .    .    0 10 1 14 1 0 0 1
                       .    .    0 14 1 17 0 1 . 1
                    8.75    .    0 12 2 14 1 0 0 1
                       .    .    0 13 2 17 0 1 . 1
                       .    .   15 12 1 13 1 0 0 1
                       .    .    0  9 2 18 0 1 0 1
                   21.26    .    0 13 1 14 1 0 0 1
                       .    .    0 10 1 21 1 0 0 1
                       .    .    0  7 1 14 1 0 0 1
                   12.34    .    0 12 2  7 1 0 0 1
                       .    . 19.9  6 2 12 1 0 . 1
      end
      label values hourpay HOURPAY5
      label values hrrate HRRATE5
      label def HRRATE5 998 "Don't know", modify
      label values ages AGES5
      label def AGES5 5 "20-24yrs", modify
      label def AGES5 6 "25-29yrs", modify
      label def AGES5 7 "30-34yrs", modify
      label def AGES5 8 "35-39yrs", modify
      label def AGES5 9 "40-44yrs", modify
      label def AGES5 10 "45-49yrs", modify
      label def AGES5 11 "50-54yrs", modify
      label def AGES5 12 "55-59yrs", modify
      label def AGES5 13 "60-64yrs", modify
      label def AGES5 14 "65-69yrs", modify
      label values sex SEX
      label def SEX 1 "Male", modify
      label def SEX 2 "Female", modify
      label values industry1 industry
      label def industry 1 "Accommodation And Food Service Activities", modify
      label def industry 2 "Administrative And Support Service Activities", modify
      label def industry 4 "Arts, Entertainment And Recreation", modify
      label def industry 5 "Construction", modify
      label def industry 7 "Education", modify
      label def industry 8 "Electricity, gas, air cond supply", modify
      label def industry 9 "Extraterritorial organisations", modify
      label def industry 10 "Financial and insurance activities", modify
      label def industry 12 "Human Health And Social Work Activities", modify
      label def industry 13 "Information And Communication", modify
      label def industry 14 "Manufacturing", modify
      label def industry 17 "Other service activities", modify
      label def industry 18 "Professional, Scientific And Technical Activities", modify
      label def industry 19 "Public admin and defence", modify
      label def industry 21 "Transportation And Storage", modify
      label def industry 23 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles", modify
      label values publicr PUBLICR5
      label def PUBLICR5 1 "Private", modify
      label def PUBLICR5 2 "Public", modify

      I tried to use this command :
      Code:
      dtable hourpay hrrate lockdwon i.ages i.sex i.industry1 full_time part_time temporary_job1 i.publicr , by(ZHC ) sample(,  place(seplabels)) sformat("(N=%s)" frequency) nformat(%7.2f mean sd) title(Table 1. Descriptive statistics) note(Mean (Standard deviation))
      this should give me a summary with missing value. However when I add the nomissing in the command also it gave me the same result !!
      Code:
      dtable hourpay hrrate lockdwon i.ages i.sex i.industry1 full_time part_time temporary_job1 i.publicr , by(ZHC, nomissing ) sample(,  place(seplabels)) sformat("(N=%s)" frequency) nformat(%7.2f mean sd) title(Table 1. Descriptive statistics) note(Mean (Standard deviation)) export(table1.docx, replace)
      so this mean all these command gave me the same summary table

      Comment


      • #4
        Thanks,

        The ZHC variable is missing, so I had to create one like the followings.

        Code:
        gen temp = runiform()
        gen ZHC = (temp > 0.4)
        replace ZHC = . if temp > 0.8
        The two commands are the same because "nomissing" is the default. If you want a table with an extra column that shows data where ZHC is a missing, then the option should be "by(ZHC, missing)":

        However, that only manages the presentation of missing in ZHC, not the missing values in the row variables. If you do not want to count missing, then nothing needs to be done because they are already excluded. But if you want to only include cases with no missing in all values, use the listwise option, here is the explanation from the technical document:

        listwise and nolistwise specify how to handle missing values across the continuous and factor variables.
        listwise handles missing values through listwise deletion, meaning that the entire observation is omitted
        from the sample if any continuous or factor variable is missing for that observation; nolistwise
        specifies that dtable omit an observation only if all the continuous and factor variables are missing for
        that observation.

        Comment

        Working...
        X