Announcement

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

  • Format display decimal

    Hi everyone,

    I don't understand why this is not formatting in two decimals

    Code:
    sysuse auto, clear
    sum price, meanonly
    di r(mean), %9.2f
    Thanks

  • #2
    Code:
    display %9.2f r(mean)
    See the help. Where given, formats precede expressions.

    Comment


    • #3
      You mean sometimes you have to say the format before the command? In wich occations, then? Thank you nick, Joan

      Comment


      • #4
        As said, it's explained in the help.

        What you are using (see http://www.stata.com/help.cgi?display) is of the form

        [%fmt] [=]exp

        which means that you can specify a format before an expression (in your case the expression r(mean))

        You can put it afterwards, but as you found that format will be ignored unless, in turn, it is followed by another expression.

        Unless you learn to read help entries, your progress in Stata will be very slow.

        Comment


        • #5
          Hi Nick,

          I do read helps and check google before writing in statalist. It is true that even if I am learning I still find help files tricky because lots of things I don't know what they are talking about because I am not an expert and only use stata some times. For example: when I read
          Code:
          help tabulate oneway
          I cannot see whether if the format goes before or after the command. I can see it in
          Code:
          help display
          instead
          I learn more easyly by examples, this is why I think there should be more of them.

          Thank for your valuable help and comments

          Joan

          Comment


          • #6
            tabulate oneway doesn't allow format specification, so I do not understand that example.

            To the point, display is a slightly complicated command, but in reading the help you can just ignore what makes no sense, and in the case here fmt and exp are clickable keywords.

            In essence, the reason I can answer these questions is that ... I read the help and I tried examples. It's the only way.

            Comment

            Working...
            X