Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: adding quotes to a macro or variable


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: adding quotes to a macro or variable
Date   Mon, 17 Mar 2008 16:47:44 -0500

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/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index