Announcement

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

  • Create a Missing value table using Putdocx

    Hi,

    I am trying to create a Word with missing value table using Putdocx.

    For this purpose I am using missings from SSC and misstable commands.

    Lamentably I had failed trying to export to Word file using Putdocx. I only get a portion of a original table. example:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id female race ses schtyp prog read write math science socst)
     70 0 4 1 1 1 57 52 .  . 57
    121 1 4 2 1 3 68 59 .  . 61
     86 0 4 3 1 1 44 33 .  . 31
    141 0 4 3 1 3 63 44 .  . 56
    172 0 4 2 1 2 47 52 .  . 61
    113 0 4 2 1 2 44 52 .  . 61
     50 0 3 2 1 1 50 59 .  . 61
     11 0 1 2 1 2 34 46 .  . 36
     84 0 4 2 1 1 63 57 .  . 51
     48 0 3 2 1 2 57 55 .  . 51
     75 0 4 2 1 3 60 46 .  . 61
     60 0 4 2 1 2 57 65 .  . 61
     95 0 4 3 1 2 73 60 .  . 71
    104 0 4 3 1 2 54 63 .  . 46
     38 0 3 1 1 2 45 57 .  . 56
    115 0 4 1 1 1 42 49 .  . 56
     76 0 4 3 1 2 47 52 .  . 56
    195 0 4 2 2 1 57 57 .  . 56
    114 0 4 3 1 2 68 65 .  . 61
     85 0 4 2 1 1 55 39 .  . 46
    167 0 4 2 1 1 63 49 .  . 41
    143 0 4 2 1 3 63 63 .  . 66
     41 0 3 2 1 2 50 40 .  . 56
     20 0 1 3 1 2 60 52 .  . 61
     12 0 1 2 1 3 37 44 .  . 46
     53 0 3 2 1 3 34 37 .  . 31
    154 0 4 3 1 2 65 65 .  . 66
    178 0 4 2 2 3 47 57 .  . 46
    196 0 4 3 2 2 44 38 .  . 46
     29 0 2 1 1 1 52 44 .  . 41
    126 0 4 2 1 1 42 31 .  . 51
    103 0 4 3 1 2 76 52 .  . 61
    192 0 4 3 2 2 65 67 .  . 71
    150 0 4 2 1 3 42 41 .  . 31
    199 0 4 3 2 2 52 59 .  . 61
    144 0 4 3 1 1 60 65 .  . 66
    200 0 4 2 2 2 68 54 .  . 66
     80 0 4 3 1 2 65 62 .  . 66
     16 0 1 1 1 3 47 31 .  . 36
    153 0 4 2 1 3 39 31 .  . 51
    176 0 4 2 2 2 47 47 .  . 51
    177 0 4 2 2 2 55 59 .  . 51
    168 0 4 2 1 2 52 54 .  . 51
     40 0 3 1 1 1 42 41 .  . 41
     62 0 4 3 1 1 65 65 .  . 66
    169 0 4 1 1 1 55 59 .  . 46
     49 0 3 3 1 3 50 40 .  . 47
    136 0 4 2 1 2 65 59 .  . 51
    189 0 4 2 2 2 47 59 .  . 46
      7 0 1 2 1 2 57 54 .  . 51
     27 0 2 2 1 2 53 61 .  . 56
    128 0 4 3 1 2 39 33 .  . 41
     21 0 1 2 1 1 44 44 .  . 46
    183 0 4 2 2 2 63 59 .  . 71
    132 0 4 2 1 2 73 62 .  . 66
     15 0 1 3 1 3 39 39 .  . 42
     67 0 4 1 1 3 37 37 .  . 32
     22 0 1 2 1 3 42 39 .  . 46
    185 0 4 2 2 2 63 57 .  . 41
      9 0 1 2 1 3 48 49 .  . 51
    181 0 4 2 2 2 50 46 .  . 61
    170 0 4 3 1 2 47 62 .  . 66
    134 0 4 1 1 1 44 44 .  . 46
    108 0 4 2 1 1 34 33 .  . 36
    197 0 4 3 2 2 50 42 .  . 61
    140 0 4 2 1 3 44 41 .  . 26
    171 0 4 2 1 2 60 54 .  . 66
    107 0 4 1 1 3 47 39 .  . 26
     81 0 4 1 1 2 63 43 .  . 44
     18 0 1 2 1 3 50 33 .  . 36
    155 0 4 2 1 1 44 44 .  . 51
     97 0 4 3 1 2 60 54 .  . 61
     68 0 4 2 1 2 73 67 .  . 66
    157 0 4 2 1 1 68 59 .  . 66
     56 0 4 2 1 3 55 45 .  . 51
      5 0 1 1 1 2 47 40 .  . 31
    159 0 4 3 1 2 55 61 .  . 61
    123 0 4 3 1 1 68 59 .  . 66
    164 0 4 2 1 3 31 36 . 39 46
     14 0 1 3 1 2 47 41 .  . 56
    127 0 4 3 1 2 63 59 .  . 56
    165 0 4 1 1 3 36 49 .  . 36
    174 0 4 2 2 2 68 59 .  . 56
      3 0 1 1 1 2 63 65 .  . 56
     58 0 4 2 1 3 55 41 .  . 41
    146 0 4 3 1 2 55 62 .  . 66
    102 0 4 3 1 2 52 41 .  . 56
    117 0 4 3 1 3 34 49 .  . 56
    133 0 4 2 1 3 50 31 .  . 31
     94 0 4 3 1 2 55 49 .  . 56
     24 0 2 2 1 2 52 62 .  . 46
    149 0 4 1 1 1 63 49 .  . 46
     82 1 4 3 1 2 68 62 .  . 61
      8 1 1 1 1 2 39 44 .  . 48
    129 1 4 1 1 1 44 44 .  . 51
    173 1 4 1 1 1 50 62 .  . 51
     57 1 4 2 1 2 71 65 .  . 56
    100 1 4 3 1 2 63 65 .  . 71
      1 1 1 1 1 3 34 44 .  . 41
    194 1 4 3 2 2 63 63 .  . 61
    end
    label values female fl
    label def fl 0 "male", modify
    label def fl 1 "female", modify
    label values race rl
    label def rl 1 "hispanic", modify
    label def rl 2 "asian", modify
    label def rl 3 "african-amer", modify
    label def rl 4 "white", modify
    label values ses sl
    label def sl 1 "low", modify
    label def sl 2 "middle", modify
    label def sl 3 "high", modify
    label values schtyp scl
    label def scl 1 "public", modify
    label def scl 2 "private", modify
    label values prog sel
    label def sel 1 "general", modify
    label def sel 2 "academic", modify
    label def sel 3 "vocation", modify
    
    putdocx begin
    
    *The original table work ok
    *My goal is export this table
    
    missings report, percent sort
    
      +---------------------------------+
      |           # missing   % missing |
      |---------------------------------|
      |    math         200      100.00 |
      | science         198       99.00 |
      +---------------------------------+
    
    *I used table to export using Putdocx, but I got a incomplete table:
    
    table (command) (result), command(missings report, percent sort)
    putdocx collect
    
    ------------------------------------
                                  |    N
    ------------------------------+-----
    missings report, percent sort |  200
    ------------------------------------
    
    
    *Other way is work with stored information
    *but return list only return incomplete information
    
    quit missings report, percent sort
    return  list
    
    
    scalars:
                      r(N) =  200
    
    macros:
                r(varlist) : "math science"
    
    
    *Another command to get missing values table: misstable
    *But I got the same problem: I only export an incomplete table
    
    *The original table work ok
    
    misstable summarize
                                                                   Obs<.
                                                    +------------------------------
                   |                                | Unique
          Variable |     Obs=.     Obs>.     Obs<.  | values        Min         Max
      -------------+--------------------------------+------------------------------
              math |       200                   0  |      0          .           .
           science |       198                   2  |      2         39          44
      -----------------------------------------------------------------------------
    
    
    *Again I used table to export using Putdocx, but I got an incomplete table:
    
    table  (result)  (command), command( misstable summarize)
    putdocx collect
    
    ------------------------------------------------------------------------
                                                      |  misstable summarize
    --------------------------------------------------+---------------------
    Number of unique, nonmissing values               |                    2
    Number of observations containing .               |                  198
    Number of observations containing .a, .b, ..., .z |                    0
    Number of observations containing nonmissing      |                    2
    Maximum value                                     |                   44
    Minimum                                           |                   39
    ------------------------------------------------------------------------
    
    putdocx collect
    
    *Again return list only return incomplete information:
    
    quiet misstable summarize
    ret li
    
    scalars:
                 r(K_uniq) =  2
               r(N_gt_dot) =  0
               r(N_eq_dot) =  198
                    r(max) =  44
                    r(min) =  39
               r(N_lt_dot) =  2
    
    macros:
                r(vartype) : "numeric"
    
    putdocx save "C:\test", replace
    Any comment I will appreciate
    Thanks in advance
    Rodrigo
    Last edited by Rodrigo Badilla; 05 Oct 2023, 09:26.
Working...
X