Announcement

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

  • display format

    I have a numeric variable that contains some large numbers (up to 10 digits long).
    The variable format is %12.0g. I can see the full-length number in the data view window but when I tabulate this variable, in the results window it shows the shorthand version (e.g. 5.04e+8), instead of the full-length number.
    Is there a way to view the full-length number in the results window when running a tab command?
    Many thanks

  • #2
    No example data or precise commands here.

    Instead of tabulate, consider table, tabdisp, list, etc. Which might be good will depend on the details you don't give.

    Comment


    • #3
      Hi Nick, thanks for your reply.

      For example:
      year id
      2000 123456789
      2000 987654321
      format id %12.0g
      tab id

      produces...

      id | Freq. Percent Cum.
      ------------+-----------------------------------
      1.23e+08 | 1 50.00 50.00
      9.88e+08 | 1 50.00 100.00
      ------------+-----------------------------------
      Total | 2 100.00


      ...whereas I would like it to display:

      id | Freq. Percent Cum.
      ------------+-----------------------------------
      123456789 | 1 50.00 50.00
      987654321 | 1 50.00 100.00
      ------------+-----------------------------------
      Total | 2 100.00


      Any advice on this would be greatly appreciated!
      Thanks
      Last edited by tim bradshaw; 08 Jan 2018, 08:32.

      Comment


      • #4
        Ah, 'table' did the trick - thank you!

        Comment


        • #5
          Actually, now there is the same problem with 'table' but in the frequency count column.

          Comment


          • #6
            Thanks for the example.

            Code:
            tab id
            works fine for me so long as you first change the display format of id to something like

            Code:
            format id %10.0f

            Comment


            • #7
              Got it, thanks

              Comment


              • #8
                Hi again Nick, do you find that negative numbers are still shortened in the results window when using the following command?
                Code:
                 format id %10.0f
                
                tab id

                Comment


                • #9
                  As before, please give data examples explicitly. Here groups (Stata Journal) seems a possibility.


                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input float year double id
                  2000 -123456789
                  2000 -987654321
                  end
                  
                  format id %12.0f
                  
                  tab id
                  
                           id |      Freq.     Percent        Cum.
                  ------------+-----------------------------------
                    -9.88e+08 |          1       50.00       50.00
                    -1.23e+08 |          1       50.00      100.00
                  ------------+-----------------------------------
                        Total |          2      100.00
                  
                  groups id
                  
                    +---------------------------------------+
                    |         id   Freq.   Percent      %<= |
                    |---------------------------------------|
                    | -987654321       1     50.00    50.00 |
                    | -123456789       1     50.00   100.00 |
                    +---------------------------------------+

                  Comment


                  • #10
                    Tim,

                    1. tabulating IDs is rarely a productive task. If you have 10-digit IDs then you probably have a lot of them, resulting in some mega-tables, not digestible by humans.

                    2. consider collapsing your dataset by ID, then listing the resulting dataset.

                    3. another possibility is to generate myid=string(id) with some format, then tabulate myid. Here you have full control over how you create a string (readable) representation of ID.

                    4. avoid tabulate command as much as possible and use table command instead.


                    Code:
                    clear
                    input float year double id
                    2000 -123456789
                    2000 -987654321
                    end
                    
                    expand 100000
                    
                    format id %20.0gc
                    table id, format(%20.0gc)
                    
                    format id %20.0g
                    table id, format(%20.0g)
                    Output
                    Code:
                    . format id %20.0gc
                    . table id, format(%20.0gc)
                    -----------------------------------
                              id |                Freq.
                    -------------+---------------------
                    -987,654,321 |              100,000
                    -123,456,789 |              100,000
                    -----------------------------------
                    . format id %20.0g
                    . table id, format(%20.0g)
                    ---------------------------------
                            id |                Freq.
                    -----------+---------------------
                    -987654321 |               100000
                    -123456789 |               100000
                    ---------------------------------
                    Best, Sergiy

                    Comment


                    • #11
                      Same probelem is being faced when using table to do sum of a numeric varibale across a catrorical variable
                      See 2.73e+07
                      How to het the actual number diplayed
                      Tried all combinations in varibale propoerties (Long/double)

                      Comment


                      • #12
                        Region sum(ER4)

                        ARO 2385917
                        AWR 56968
                        EN 1039412
                        ESEAOR 2.73e+07
                        SARO 376872
                        WHR 774809

                        Comment


                        • #13
                          Please study the Statalist FAQ

                          https://www.statalist.org/forums/help#realnames

                          https://www.statalist.org/forums/help#question

                          https://www.statalist.org/forums/help#stata

                          I can't say that you have a question that isn't already answered in this thread.

                          A display format like %8.0f will show numbers like 27312345 with all digits shown.

                          Comment


                          • #14
                            I am having the same problem.
                            I can display the variable in the format I want but the output of the statistical tests using the variable (i.e. ttest) is in the imprecise format.

                            Comment


                            • #15
                              re: #14 - it is not clear what part of the output you are complaining about, but see
                              Code:
                              help pformat

                              Comment

                              Working...
                              X