Announcement

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

  • add zero to a number.

    Dear All, How can I add a zero just before the second last digit of a number? The data set is:
    Code:
    // https://bbs.pinggu.org/thread-10970213-1-1.html
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double ID double wanted 
    110101003101 1101010031001
    110101007102 1101010071002
    end
    format ID wanted %14.0f
    I have this "ID" variable (12 digits), but wish to obtain a (13-digit) variable "wanted".
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    Code:
    gen double wanted = 1000*floor(ID/100) + mod(ID, 100)

    Comment


    • #3
      Dear Clyde, Thanks a lot.
      Ho-Chuan (River) Huang
      Stata 17.0, MP(4)

      Comment

      Working...
      X