Announcement

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

  • Macro trimming

    Just spent an hour debugging the code which was producing misaligned output until I realized that the code was run under the version control for v8.2.

    The following example demonstrates the difference in behavior I have encountered:

    Code:
    version 8.2
    local a="    "+string(1,"%8.2f")
    display `"`a'"'
    
    version 18.0
    local a="    "+string(1,"%8.2f")
    display `"`a'"'
    The output was:

    Code:
    . version 8.2
    
    . local a="    "+string(1,"%8.2f")
    
    . display `"`a'"'
    1.00
    
    . 
    . version 18.0
    
    . local a="    "+string(1,"%8.2f")
    
    . display `"`a'"'
        1.00
    
    . 
    end of do-file

    Note also that under any version of Stata whatever the format is being used ("%8.2f" or "%18.2f", etc) it doesn't make any difference on the resulting macro content, which also came as a surprise.

    Clearly once I know where the issue is, it is really no problem to work around it, but finding it was a journey.
    Hope this saves some time to someone who experiences the same issue in the future.

    Best, Sergiy Radyakin






Working...
X