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 <pschumm@uchicago.edu>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index