Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Re: string functions quotation marks


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: string functions quotation marks
Date   Sat, 24 Sep 2011 16:14:29 +0100

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 <euslaner@gvpt.umd.edu> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index