I have some variables with dollar signs (i.e., $
) in the variable labels. This causes some problems downstream in my code (I later modify these labels and the dollar signs deregister as empty global macros). So I would like to replace these dollar signs with LaTeX's \textdollar
using Stata's subinstr()
function.
But I can't figure it out. Is this possible? Or should I resign to doing this more manually? Or by looking for other characters near or around the $
in the variable labels?
clear
set obs 10
generate x = runiform()
label variable x "Label with $mil"
generate y = runiform()
label variable y "Another label with $mil"
describe
foreach v of varlist * {
local name : variable label `v'
local name `=subinstr("`name'", "$mil", "\textdollar", .)'
label variable `v' "`name'"
}
describe
This removes the label altogether.