Dear All
Stata's classutil command is a utility for working with classes and objects.
Specifically classutil des .someObject lists the properties defined for .someObject.
It turns out that it does this in an unsafe manner, meaning that if a dollar sign occurs in the value of the property, it is not displayed verbatim, but rather interpreted as a beginning of a macro.
Consider the following minimal example.
First define a class file foobar.class and save it somewhere along your Stata's search path (for example, in the current directory):
Second, execute the following code:
The output looks like this:

I don't see any real-world scenario where such output of classutil des would be useful and consider it a bug.
The behavior I expect here is exhibited, for example, in the following:
which does not attempt to evaluate special characters in the variable label (displays the label of the variable x with a proper dollar sign and subsequent text intact):

Hope this can be agreed as a bug and fixed (if not already).
Thank you and have a good weekend!
Sergiy
StataNow/MP 19.5 for Windows (64-bit x86-64) | Revision 14 Jan 2026 | Windows
Stata's classutil command is a utility for working with classes and objects.
Specifically classutil des .someObject lists the properties defined for .someObject.
It turns out that it does this in an unsafe manner, meaning that if a dollar sign occurs in the value of the property, it is not displayed verbatim, but rather interpreted as a beginning of a macro.
Consider the following minimal example.
First define a class file foobar.class and save it somewhere along your Stata's search path (for example, in the current directory):
Code:
// 2026 Sergiy Radyakin
class foobar {
string storage
}
program define .new
args d
display _n as text `"`macval(d)'"'
.storage = "`macval(d)'"
end
// END OF FILE
Code:
clear all .g=.foobar.new "Te\$st" display `"`macval(.g.storage)'"' classutil des .g // END OF FILE
I don't see any real-world scenario where such output of classutil des would be useful and consider it a bug.
The behavior I expect here is exhibited, for example, in the following:
Code:
clear all gen x=1 label variable x "Te\$st" describe
Hope this can be agreed as a bug and fixed (if not already).
Thank you and have a good weekend!
Sergiy
StataNow/MP 19.5 for Windows (64-bit x86-64) | Revision 14 Jan 2026 | Windows
