Announcement

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

  • Number format on output tables

    Hi,
    I am new on using STATA. I have a quite basic question.
    For example, when using the command “summarize” on the resulting table the numbers (i.e. mean, standard deviation) are appearing all together, without any separator between them as for example the thousands separator. How can be defined thousands separator so numbers are easier to read?
    Thanks in advance


  • #2
    Telmo:
    see -help format-.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Carlo pointed you to the right track. It is important to get a good grasp on formatting values.

      Since you said you are new to Stata, this is a toy example:

      Code:
      . sysuse auto
      (1978 Automobile Data)
      
      . tab foreign, su(mpg)
      
                  |      Summary of Mileage (mpg)
         Car type |        Mean   Std. Dev.       Freq.
      ------------+------------------------------------
         Domestic |   19.826923   4.7432972          52
          Foreign |   24.772727   6.6111869          22
      ------------+------------------------------------
            Total |   21.297297   5.7855032          74
      
      . format mpg %9.2f
      
      . tab foreign, su(mpg)
      
                  |      Summary of Mileage (mpg)
         Car type |        Mean   Std. Dev.       Freq.
      ------------+------------------------------------
         Domestic |       19.83        4.74          52
          Foreign |       24.77        6.61          22
      ------------+------------------------------------
            Total |       21.30        5.79          74
      
      */ To get commas as a separator for thousands, you may type (here, we created a variable for that:
      
      . gen mpg1000 = mpg*1000
      
      . tab foreign, su(mpg1000)
      
                  |         Summary of mpg1000
         Car type |        Mean   Std. Dev.       Freq.
      ------------+------------------------------------
         Domestic |   19826.923   4743.2972          52
          Foreign |   24772.727   6611.1869          22
      ------------+------------------------------------
            Total |   21297.297   5785.5032          74
      
      . format mpg1000 %12.2fc
      
      . tab foreign, su(mpg1000)
      
                  |         Summary of mpg1000
         Car type |        Mean   Std. Dev.       Freq.
      ------------+------------------------------------
         Domestic |   19,826.92    4,743.30          52
          Foreign |   24,772.73    6,611.19          22
      ------------+------------------------------------
            Total |   21,297.30    5,785.50          74
      Hopefully it helps.
      Last edited by Marcos Almeida; 24 Jul 2017, 07:50.
      Best regards,

      Marcos

      Comment


      • #4
        Hi,

        Thanks for your note Marcos and also to Carlo Lazzaro that pointed to the right track on the topic. As I referred I just started using STATA so I am trying to have a first understanding of commands.

        Best regards

        Telmo Vieira
        Last edited by Telmo Vieira; 25 Jul 2017, 01:28.

        Comment

        Working...
        X