Announcement

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

  • Formating tabulate command output: From scientific notation to fixed digits

    Hi all

    After I am running the tabulate command, I get this:


    indus | Freq. Percent Cum.
    ------------+-----------------------------------
    1.01e+07 | 34 0.03 0.03
    1.01e+07 | 561 0.58 0.61
    1.01e+07 | 34 0.03 0.65
    1.01e+07 | 289 0.30 0.94
    1.01e+07 | 561 0.58 1.52
    1.01e+07 | 238 0.24 1.76
    1.01e+07 | 170 0.17 1.94
    1.51e+07 | 3,196 3.28 5.21
    1.51e+07 | 323 0.33 5.54
    1.51e+07 | 884 0.91 6.45
    1.51e+07 | 187 0.19 6.64
    1.51e+07 | 2,346 2.41 9.05
    1.51e+07 | 1,785 1.83 10.88

    I would like to get the output of indus as fixed digits instead of scientific notation as above.
    Kindly help
    Regards






  • #2
    Use a string version of that numeric variable.

    Code:
     
    . clear
    
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . gen double whatever = cond(_n < 6, 12345678, 87644321)
    
    . tab whatever
    
       whatever |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       1.23e+07 |          5       50.00       50.00
       8.76e+07 |          5       50.00      100.00
    ------------+-----------------------------------
          Total |         10      100.00
    
    . gen somethingelse = string(whatever, "%9.0f")
    
    . tab somethingelse
    
    somethingel |
             se |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       12345678 |          5       50.00       50.00
       87644321 |          5       50.00      100.00
    ------------+-----------------------------------
          Total |         10      100.00

    Comment

    Working...
    X