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

Re: st: adding quotes to a macro or variable

From   Phil Schumm <>
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

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'"'

-- Phil

* For searches and help try:

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