statamath

scalar arithmetic in Stata


Riddle me this:

scalar bah = .1*1000.01
display bah

   1

scalar list

   bah =    100.001

display seems to deliberately show the wrong number. Why? What is the standard way of checking the value of a scalar? scalar list seems like it would be a mess if using many scalars.


Solution

  • Try something like:

    display %18.0g bah
    

    (See help format)

    or

    display scalar(bah)
    

    See also help scalar and the respective manual entry [P] scalar