For the most part it seems to work fine, and returns the numbers I'm expecting:
Code:
nicenum demo = 0 20 di $demo di "$demo"
But with some macro names I get very different results:
Code:
nicenum longmacro = 0 20 di $longmacro * Result: 20
Code:
clear all macro drop _all // Long macro name nicenum longmacro = 0 20 di $longmacro * Result: 20 // Eight-character macro name nicenum longmacr = 0 20 di $longmacr * Result: 0 5 10 15 20 // Long macro name again nicenum longmacro = 0 20 di $longmacro * Result: 0 5 10 15 20 20
Code:
// Start with the long macro name clear all macro drop _all nicenum longmacro = 0 20 di $longmacro * Result: 20 // Start with the eight-character macro name clear all macro drop _all nicenum longmacr = 0 20 di $longmacr * Result: 0 5 10 15 20 nicenum longmacro = 0 20 di $longmacro * Result: 0 5 10 15 20 20
Obviously, this isn't really a 'problem' since I can just use shorter macro names that seem to work. But it took me a while to figure out why I was getting strange results some of the time, and that made me curious about what's behind this behaviour. So I thought it might be worth (a) documenting and (b) asking whether anyone can shed any light on what's driving this?
*** Technical details ***
I'm using Stata version 14.2 on Windows 7 Professional.
-nicenum- is written by James W. Hardin and is available via -findit nicenum- (package number dm28).
0 Response to Unexpected results from -nicenum-
Post a Comment