Is there a quick way to count the zeros in a number? For example, 500 000 has five zeros.
-
Login or Register
- Log in with
clear input numeric 42 666 10 100 1000 10000 end tostring numeric, generate(string) gen nzero = length(string) - length(subinstr(string, "0", "", .)) list, sep(0) +--------------------------+ | numeric string nzero | |--------------------------| 1. | 42 42 0 | 2. | 666 666 0 | 3. | 10 10 1 | 4. | 100 100 2 | 5. | 1000 1000 3 | 6. | 10000 10000 4 | +--------------------------+
Comment