Announcement

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

  • Issues with dtable command.

    I recently updated to Stata18 and was hoping to try out the dtable command. When using nhanes data, the command works as advertised.

    However, when I attempt to generate a new string variable or new byte variable from the nhanes data - in this case, I chose to generate another Sex variable [generate byte Sex1 = sex] - I get an r(9999); error message. Basically, any new variable I generate causes this error to appear. Any advice on how to rectify this? Thank you for your time.

    Click image for larger version

Name:	IMG_3594.png
Views:	1
Size:	307.3 KB
ID:	1713469

  • #2
    I am unable to reproduce your problem on my setup. The same code runs fine:
    Code:
    . webuse nhanes2l, clear
    (Second National Health and Nutrition Examination Survey)
    
    .
    . dtable age weight bpsystol i.sex i.race
    
    ----------------------------------------
                                 Summary    
    ----------------------------------------
    N                                 10,351
    Age (years)              47.580 (17.215)
    Weight (kg)              71.898 (15.356)
    Systolic blood pressure 130.882 (23.333)
    Sex                                    
      Male                     4,915 (47.5%)
      Female                   5,436 (52.5%)
    Race                                    
      White                    9,065 (87.6%)
      Black                    1,086 (10.5%)
      Other                       200 (1.9%)
    ----------------------------------------
    
    .
    . gen byte sex1 = sex
    
    . tab sex1 sex
    
               |          Sex
          sex1 |      Male     Female |     Total
    -----------+----------------------+----------
             1 |     4,915          0 |     4,915
             2 |         0      5,436 |     5,436
    -----------+----------------------+----------
         Total |     4,915      5,436 |    10,351
    
    .
    Moreover, there isn't supposed to be a 9999 error code. So I think something is likely wrong with your Stata installation. If I were you, I would uninstall Stata 18 and reinstall it from scratch. If the problem persists, I think you should contact Technical Support about this.

    Comment


    • #3
      Thank you, Mr. Schechter. I should clarify - the error message appears when I try to rerun the dtable command with the new variable. When attempting to use any string variable, I also get the 'string vars not allowed in varlist' error code before the r(9999); code appears.

      Comment


      • #4
        For others that may be having the same problem - this error appears when the varname has a capital letter.

        Comment


        • #5
          Can confirm - if the first letter is capitalized then -dtable- gives error cod 9999.

          Code:
          webuse nhanes2l, clear
          rename age Age
          dtable Age

          Comment


          • #6
            Ah, I misunderstood the original post. I, too, now have difficulties with -dtable- when there is a variable beginning with an upper case letter.
            Code:
            . clear*
            
            . webuse nhanes2l
            (Second National Health and Nutrition Examination Survey)
            
            . dtable sex
            
            -----------------
                   Summary  
            -----------------
            N          10,351
            Sex 1.525 (0.499)
            -----------------
            
            . rename sex Sex
            
            . dtable Sex
            r(9999);
            Then, it occurred to me that perhaps this was a problem because, for a factor-variable, -dtable- expects an i. prefix. Perhaps it's just an incorrect error message that is supposed to instead be a warning about factor variable notation. So I tried that and got, to my surprise:

            Code:
            . dtable i.Sex
            factor-variable operators not allowed on latent variable Sex
            r(198);
            This kind of message ought to be coming out of -sem-, not -dtable-. And -dtable- should work with all legal variable names.

            So, yes, something is definitely wrong with -dtable- and variable names beginning with upper case.

            While the StataCorp team does follow the Forum, it wouldn't hurt to report this directly to Tech Support.

            Comment


            • #7
              Also note the use of a continuous variable in my earlier example (age), so definitely not limited to factor variables.

              Comment


              • #8
                dtable has a parsing bug that is causing it to exit with unhelpful error messages when a variable name with a leading capital letter is specified in the varlist.
                This also happens in options continuous() and factor().
                This should be fixed in the next Stata 18 update.

                Comment


                • #9
                  Hello. I am using dtable for summary statistics for the variables specified but separately for each category using, by (var)

                  I receive a table containing summary statistics that display column percentages. This means that the percentages on each column add up to one hundred.

                  I need a table that shows row percentages. Do you know how can I get that? Thanks!

                  This is the code:

                  . dtable usdpercapita i.zona i.sexo , by(die10_c, nototals test)

                  this is the table I get:

                  ----------------------------------------------------------------------------------------------------------------
                  die10_c. ¿con qué frecuencia revisa y toma en cuenta los sellos de advertencia
                  SIEMPRE CASI SIEMPRE ALGUNAS VECES RARA VEZ NUNCA Test
                  ----------------------------------------------------------------------------------------------------------------
                  N 1,661 (30.1%) 566 (10.3%) 532 (9.6%) 494 (8.9%) 2,267 (41.1%)
                  usdpercapita 404.456 (802.428) 349.860 (416.370) 360.858 (507.553) 302.784 (320.349) 272.651 (297.909) <0.001
                  Área geográfica
                  URBANA 1,469 (88.4%) 501 (88.5%) 446 (83.8%) 409 (82.8%) 1,820 (80.3%) <0.001
                  RURAL 192 (11.6%) 65 (11.5%) 86 (16.2%) 85 (17.2%) 447 (19.7%)
                  Sexo
                  HOMBRE 524 (31.5%) 199 (35.2%) 175 (32.9%) 166 (33.6%) 955 (42.1%) <0.001
                  MUJER 1,137 (68.5%) 367 (64.8%) 357 (67.1%) 328 (66.4%) 1,312 (57.9%)
                  ----------------------------------------------------------------------------------------------------------------


                  As you can see, the percentages are by columns, not by rows.

                  Comment


                  • #10
                    how can i use dtable in Stata 16?

                    Comment


                    • #11
                      Originally posted by shem shen View Post
                      how can i use dtable in Stata 16?
                      the short answer is that you can’t. dtable was released in Stata 18. To use it you would need to upgrade.

                      Comment


                      • #12
                        I have a silly question: if you are using dtable for the first time, do you have to create a word doc and then send the table to that designated word doc? i'm a little confused how dtable works. I am able to create the table fine, but i just can't export it. Every time I run: export myfile.docx
                        I end up getting export error: unknown subcommand "myfile.docx"

                        I just assumed dtable would create a file automatically on my desktop or in my stata folder.

                        I know this is perhaps a stupid question. any ideas?

                        Comment


                        • #13
                          one of the options to the command is "as()" where you put in parens the fileformat you want (e.g., "docx") - note that there are docx options; see
                          Code:
                          h dtable
                          and search for, or scroll down to, the "as()" option where you can click on "docx options" to see what is available

                          Comment


                          • #14
                            Do I need to specify a location where stata should create the doc, or is that something that is automatically to desktop?

                            Comment


                            • #15
                              Jeff Pitblado (StataCorp)

                              Comment

                              Working...
                              X