[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: adding quotes to a macro or variable
On Mar 17, 2008, at 4:18 PM, Laura Gibbons wrote:
Is there any way I could change a macro value from xxx to "xxx".
local l `""xxx""'
. local l='"`l'"'
'"xxx"' invalid name
r(198);
Notice that your first single quote is ' rather than ` (i.e., a
backtick), which is why you got the error. What you want are called
compound double quotes (`" and "') -- these can be used in Stata just
like " and " to delimit strings, with the advantage that double
quotes embedded within the string are handled properly. And, what's
extra nifty is that they nest, i.e.,
. local l `"`"xxx"'"'
. di `"`l'"'
`"xxx"'
-- Phil
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/