Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Replace ` and '


From   Fred Wolfe <[email protected]>
To   [email protected]
Subject   st: Replace ` and '
Date   Wed, 08 Dec 2004 09:54:48 -0600

In an email in March 2002, Nick Cox wrote that you could replace " as follows:


replace foo = subinstr(foo,`"""',"",.)

Take the second argument, which is the trickiest:

`"""' is `" as delimiter followed by " as character followed by "' as
delimiter. Make sure you start with ` (namely, a left or opening single
quote).


Using this logic with a macro using -file- and reading an ado text file

local line: subinstr local line `"""' "",all (this works)

But

local line: subinstr local line `"`"' "",all (produces "invalid syntax" message)
local line: subinstr local line `"'"' "",all (produces "invalid syntax" message)

Is this the way to code it? The problem could be within macro interpretation, but macval() doesn't help.


Thanks,

Fred


Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel (316) 263-2125 Fax (316) 263-0761
[email protected]


*
* 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