Question

When using the list command, is it possible to display additional digits of an integer--ideally the full integer--rather than to display in scientific notation?

For example, right now, I have an integer that is displayed at 1.90e+10 whereas I believe the full value is 19001000001. Ideally, I'd like to get that full value, or at least additional decimal points beyond the two provided (that is, the 9 and the 0).

I am using Stata SE 11.1.

Was it helpful?

Solution

Just set the display format with the format command before using list.

. set obs 1
obs was 0, now 1

. gen double y = 987654321

. l y

    +-----------+
    |         y |
    |-----------|
 1. | 9.877e+08 |
    +-----------+

. format y %16.0f

. l y

    +-----------+
    |         y |
    |-----------|
 1. | 987654321 |
    +-----------+

If list will not play, its display option will enforce use of the display format. That was not needed in this example. The format I chose here was arbitrary. Stata tends not to insert spaces that are not needed, so just choose a number rather bigger than the length of your integer.

(LATER) Focusing on your example: you gave an example of an integer that should be 19001000001. Assuming that this is a real (or realistic) example for you, note that float type does not use enough bits to hold this accurately, long can't hold integers that big, and your only possibility to hold this as a numeric variable is double.

. set obs 1
obs was 0, now 1

. gen y1 = 19001000001

. gen double y2 = 19001000001

. gen long y3 = 19001000001

. l

      +---------------------------+
      |       y1          y2   y3 |
      |---------------------------|
   1. | 1.90e+10   1.900e+10    . |
      +---------------------------+

 . format y* %16.0f

 . l

        +--------------------------------+
        |          y1            y2   y3 |
        |--------------------------------|
  1   . | 19000999936   19001000001    . |
        +--------------------------------+

On the other hand, what kind of count or measurement can you trust to that precision? Possibly this is some kind of identifier that just happens to be based on numeric characters, in which case holding it as a string variable will make some things easier, depending on what you want to do with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top