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: handling the quote character stored in a string variable
From
Dan Blanchette <[email protected]>
To
[email protected]
Subject
Re: st: handling the quote character stored in a string variable
Date
Mon, 9 Jan 2012 10:03:39 -0500 (EST)
Charles,
This is a situation where using compound quotes in Stata are required
(which is what Nick Cox suggested):
. gen type_corr= "expression" if marqueur_type2 == `"""'
This will give you more help:
. help strings
Also, when you expect that there are no leading or trailing blanks it
is good to make sure that is truly the case by using the function trim() :
. gen type_corr= "expression" if trim(marqueur_type2) == `"""'
Dan Blanchette
Research Programming Services
Carolina Population Center
University of North Carolina
[email protected]
Dear Statalisters,
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 ?
Thanks,
Charles
*
* 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/