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

st: RE: Replace ` and '


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: Replace ` and '
Date   Wed, 8 Dec 2004 16:11:30 -0000

Compound double quotes around the ` character do not seem to work (I am not sure why - I guess it is trying to interpret `"' as a macro or something), however simple double quotes will suffice in this case so try

local line: subinstr local line "`" "", all

David
[email protected]

-----Original Message-----
From: Fred Wolfe [mailto:[email protected]]
Sent: 08 December 2004 15:55
To: [email protected]
Subject: st: Replace ` and '


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/



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