Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Quote Quote Unquote Unquote??


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Quote Quote Unquote Unquote??
Date   Wed, 23 Mar 2011 14:24:57 +0000

-subinstr()- is a function, not a command.

The problem here is that the double quote character -- I will assume
that you are not concerned with single quotes -- has two roles: it can
be a string delimiter and it can stand for a literal character. Also,
if you nest double quotes, the result will be  ambiguous. The solution
to both of these problems is to use a Stata invention, compound double
quotes, in which `"  (left single quote followed by double quote) is
an opening delimiter and "' (double quote followed by right single
quote) is a closing delimiter. In terms of what you type, these are
two characters each, but they are to be interpreted as composites,
just as == and <= and >= are two characters standing for single
entities.

You want

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

Note that what you are describing is not removing double quote
characters, so much as replacing them with spaces. If you just want to
remove them, then

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

is clearly the alternative to use.

Nick

On Wed, Mar 23, 2011 at 2:05 PM, miyu Lee <[email protected]> wrote:

> I have a small issue regarding quotation marks:
>
> I want to remove all quote marks from my dataset, seems it doesnt work
> with the substring command.
>
> For example, "replace variable = subinstr( variable, """, " ",.)"
>
> (that is triple quotation marks) doesnt work, (rightly) saying "too few quotes"
>
> or: "replace variable = subinstr (variable, """", " ", .)" works -
> unfortunately removing everything within quotation marks.
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index