Announcement

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

  • #16
    Thanks. that's what I was looking for.
    Stata/MP 15.1

    Comment


    • #17
      Dear Musau,

      I have encountered a further problem when numbers are very small.

      MWE:

      Code:
      clear
      input v1 v2
      10000000000 3
      1 3
      3 3
      end
      
      estpost su v1 v2
      eststo est_1
      esttab est_1, cells("count(fmt(%12.0fc)) mean(fmt(%9.3g)) sd(fmt(%9.3g)) min(fmt(3)) max(fmt(3))")
      Click image for larger version

Name:	Screen Shot 2020-06-05 at 11.53.44.png
Views:	1
Size:	86.9 KB
ID:	1557055
      Stata/MP 15.1

      Comment


      • #18
        If a variable ranges from 1 to 10 billion, I wouldn't want to see every digit in a table, but there is scope to do it:

        Code:
        . di %9.3g 10000000000
         1.00e+10
        
        . di %12.3g 10000000000
            1.00e+10
        
        di %13.3g 10000000000
          10000000000
        Last edited by Nick Cox; 05 Jun 2020, 03:21.

        Comment


        • #19
          Thanks Nick. What about very small numbers?

          For instance:

          Code:
          di %13.3g 0.00000000001
          Stata/MP 15.1

          Comment


          • #20
            So, what is that you want? That 10 billion is shown as an integer with all zeros explicit and 1 in 100 billion is shown similarly in the same column of some output as 0.00000000001? I have to guess that is beyond any format provided with Stata -- and it also seems to imply that your column in the resulting table would need to be about 25 characters wide, unless you defy common standards of aligning numbers on the decimal point, or where it should be. Good luck in combining that readably with whatever else is going to be in your table.

            More positively, a need to show both very big and very small numbers in the same column is precisely why scientific notation is useful.

            esttab is an excellent command I never use so I can't add advice on whether or how it can be persuaded or coerced to do what you want.

            It is known that users can't define formats, except by arranging for a string variable to be produced for output using their own combination of rules, which was my point earlier in the thread.

            Comment


            • #21
              Is there a format which rounds such a small number to zero?
              Stata/MP 15.1

              Comment


              • #22
                See

                Code:
                help format
                In particular

                %g differs from %f in that (1) it decides how many digits to display to the right of
                the decimal point, and (2) it will switch to a %e format if the number is too large or
                too small.

                Some possibilities are

                Code:
                di %13.11f 0.00000000001
                di %13.0f 0.00000000001
                Res.:

                Code:
                 di %13.11f 0.00000000001
                0.00000000001
                
                .
                . di %13.0f 0.00000000001
                            0
                The good news is that esttab allows you to specify multiple display formats for results in the same column.

                Code:
                sysuse auto, clear
                replace price= price*10000000
                reg mpg weight disp price gear turn
                esttab ., b(%9.3g %9.5g %9.0f %9.2f)
                Res.:

                Code:
                . esttab ., b(%9.3g %9.5g %9.0f %9.2f)
                
                ----------------------------
                                      (1)  
                                      mpg  
                ----------------------------
                weight            -.00525**
                                  (-3.31)  
                
                displacement     .0095914  
                                   (0.82)  
                
                price                  -0   
                                  (-1.02)  
                
                gear_ratio           0.93  
                                   (0.57)  
                
                turn                -0.20  
                                  (-1.05)  
                
                _cons               41.63***
                                   (5.04)  
                ----------------------------
                N                      74  
                ----------------------------
                t statistics in parentheses
                * p<0.05, ** p<0.01, *** p<0.001
                
                .
                where the last display format is used for the remainder of the coefficients that are unspecified. Of course, we could also have simply specified

                Code:
                esttab ., b(3 5 0 2)

                Comment


                • #23
                  Thanks Andrew!
                  Stata/MP 15.1

                  Comment

                  Working...
                  X