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

Re: st: RE: Help on double or single quote search in a String


From   Tom Trikalinos <[email protected]>
To   [email protected]
Subject   Re: st: RE: Help on double or single quote search in a String
Date   Tue, 26 Oct 2004 19:29:43 +0300

Perhaps another way around is to use the _char()_ function
. index(yourStringVariable, char(n))

In MacOsX at least:
n=39 id the right single quote (')
n=96 is the left quote (`)
n=34 is the double quote (")

This is different in Windows.

To easily see what n corresponds to what character in your platform, run the following in a do-file:
forvalues i=1/255{
di "`i' for " char(`i')
}

and pick the n you need.

Cheers,
Tom

On Oct 26, 2004, at 7:13 PM, David Harrison wrote:


Use compound double quotes - ie `" for open quote and "' for close quote. So the string containing the double quote character is written as `"""'

e.g.

. di index(`"string with " quotes"',`"""')
13

David
[email protected]

-----Original Message-----
From: MITRA PINAKI (MAR1PXM) [mailto:[email protected]]
Sent: 26 October 2004 16:54
To: [email protected]
Subject: st: Help on double or single quote search in a String


Hello List,

I have a string variable which has double quotes and/or single quotes in
some of the values and I would like to delete and generate a new variable.

For example,
Old Name New Name
Brad Allred"s Brad Allreds
STEVEN" KROFF' STEVEN KROFF

How can I put the double quote <"> and/or single quote <'> in the index
string function to search for and delete it? I can't figure out the trick to
search for quotes in a string variable; I get the error message "too few
quotes" in all my attempts. Can anyone please help me with this?

Thank you,
Pinaki

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

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