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

st: RE: RE: Replace ` and '


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Replace ` and '
Date   Wed, 8 Dec 2004 17:43:51 -0000

Consider also 

local line : subinstr local line "`=char(96)'" "", all 

Nick 
[email protected] 

David Harrison
 
> 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
 
Fred Wolfe 
 
> 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.

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