In the end of the macro definition where it returns the value:
&emit
Try changing it to:
%unquote(&emit)
There are known problems in the macro language where macro quoting is not automatically removed. In the setting you describe (MPRINT code looks correct and can even cut-and-paste from the log and run it), always try %unquoting().
... View more