Announcement

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

  • concatenate (string + stata date format) issue

    Hi Gurus,

    based on the following examples

    Code:
    . local x: di%tw 3290
    . di "begin:" "`x'"
    begin:2023w15
    
    . local x: di%tw 3227
    . di "begin:" "`x'"
    begin: 2022w4
    why does does the "space" between parts, on the second example , occur?

    thks

  • #2
    The field defined by "`x'" is right justified and has 7 characters allocated to it. So when the week number is a single digit, it is padded with a blank on the left. If you don't want that, you can change the definition of local macro x to -local x: di%-tw 3227-. Then it will be left-justified and you will get no space there.
    Last edited by Clyde Schechter; 20 Apr 2023, 14:00.

    Comment


    • #3
      thanks, Prof. Clyde.

      Code:
      . di "begin:" "`:di%tw 3227'"
      begin: 2022w4
      
      . di "begin:" "`:di%-tw 3227'"
      begin:2022w4

      Comment

      Working...
      X