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]

st: RE: RE: handling the quote character stored in a string variable


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: handling the quote character stored in a string variable
Date   Mon, 9 Jan 2012 14:56:07 +0000

That last sentence will not parse as intended. Replacement: 

Therefore, you need 

either a different string delimiter `"  "' 

or to avoid using the literal character.

Nick 
[email protected] 


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 09 January 2012 14:41
To: '[email protected]'
Subject: st: RE: handling the quote character stored in a string variable

gen type_corr = "expression" if marqueur_type2 == `"""'

or 

... if marqueur_type2 == char(32) 

Stata is struggling to see your expression your way because of the dual role of ", as a string delimiter and a literal character. Therefore, you either need a different string delimiter `"  "' or to avoid using the literal character. 

Nick 
[email protected] 

Charles Vellutini

I have a string variable ("marqueur" in the code below) which contains a single quotation mark for certain observations (the data is from Google's Adwords and keywords are enclosed in quotation marks when the correspondence type is based on the exact expression). However, Stata rejects a test on the quotation mark used as a character.  I get the error message "too few quotes" when I run the following code:

      gen type_corr = "expression" if marqueur_type2 == """

and the data is like this :


                               marqueur

obs 1                     [

obs 2                     "

obs 3                     r

obs 4                     "

etc.

Any idea on how to run tests on the quotation mark stored in a string variable ?


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

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