Formatting and displaying locals in Stata -
i came across little puzzle stata's locals, display, , quotes.. consider example:
generate var1 = 54321 in 1 local test: di %10.0gc var1[1] why call:
di "`test'" returning
54,321 whereas call:
di `test' shows
54 321 what causing such behaviour?
complete sequence
(1)
. di 54,321 54 321 (2)
. di "54,231" 54,321 display interprets (1) instruction display 2 arguments, 1 one. same result last line (first) local macro test evaluated , (second) display saw result of evaluation.
the difference when quotation marks supplied thereby insist argument literal string. same result first display command same reasons given.
in short, use of local macros here quite incidental differences in results. display never sees local macro such; sees contents after evaluation. so, seeing pivots entirely on nuances in presented display.
note further while can use display format in defining contents of local macro, ends story. local not have attached format sticks it. it's string (which naturally may mean string numeric characters).
Comments
Post a Comment