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: Re: string functions quotation marks
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Re: string functions quotation marks
Date
Sat, 24 Sep 2011 16:50:33 +0100
You don't need to use -char(34)- as compound double quotes can also be used:
subinstr(countryname, `"""', "", .)
The second argument is
`" left-single-quote double-quote to be considered a composite
character and a delimiter
" double-quote to be considered as a literal character
"' double quote right-single-quote to be considered a composite
character and a delimiter
On Sat, Sep 24, 2011 at 4:14 PM, Nick Cox <[email protected]> wrote:
> This appears to refer to values in a string variable. I would
>
> . replace countryname = subinstr(countryname, char(34), "", .)
>
> . di char(34)
>
> would show that char(34) is the double quotation mark " which is what
> you want to remove.
>
> The number of quotation marks is not an issue.
>
> If delimiting quotation marks always occurred, then
>
> . replace countryname = substr(countryname, 2, length(countryname) - 2)
>
> would be another solution, but the first solution appeals to me more.
>
> Nick
>
> On Sat, Sep 24, 2011 at 4:06 PM, Eric Uslaner <[email protected]> wrote:
>
>> I have a dataset (obviously not my own) in which the names of countries are all in quotation marks. I need to get rid of the quotation marks to merge this dataset with another. However, the situation is somewhat complicated. Country names may have one word (e.g., "Canada" or "Yemen"), two words ("North Korea" is one example), three words ("United States of America" or "Yemen Arab Republic"), or more ("Democratic Republic of the Congo"). Is there a way to get rid of these quotation marks? I have read the manual and looked at help from within Stata and can't find a solution.
>
*
* 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/