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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Using substr with embedded quotes


From   Jeph Herrin <stata@spandrel.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Using substr with embedded quotes
Date   Tue, 05 Feb 2013 10:42:02 -0500

For embedded quotes you need to use `" "'. This works:

 local if `"if type=="breast""'
 local x = substr(`"`if'"',3,.)
 di `"`x'"'

or

 local if if type=="breast"
 local x = substr(`"`if'"',3,.)
 di `"`x'"'


hth,
Jeph


On 2/5/2013 10:23 AM, Simone Peart Boyce wrote:
Hi,

I have a string that contains quotes.  When I try to do use substr to extract a portion of this string, substr seems to ignore everything after the quote.  Here is my example.

local if="if type=="breast""
local x=substr("`if'",3,.)
disp "`x'"
type==

Why is "breast" being ignored?

Thanks in advance,
Simone
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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