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

st: Problems with strings starting with an apostrophe


From   "Jann, Ben" <[email protected]>
To   <[email protected]>
Subject   st: Problems with strings starting with an apostrophe
Date   Wed, 3 Mar 2004 11:46:55 +0100

Dear colleagues,

strings starting with an apostrophe (') sometimes cause weired errors
even if embraced in compound double quotes. For example

 . di 1 + match("",`"'whatever"')

produces an error, while

 . di match("",`"'whatever"') + 1

or

 . di 1 + match("","'whatever")

does not. Even odder:

 . lab def x 1 `"'whatever"' /*
    */ 2 whatever

produces an error, while

 . lab def x 1 `"'whatever"' 2 whatever

works fine. Similarly ("s" being a string variable):

 . gen x = `"'whatever"'==s

is ok, but not

 . gen x= s==`"'whatever"'

This is very anoying because it makes it hard to write programs that
work correctly. 

Does anyone know a "really" save way to treat strings?

Thanks, ben

--------------------------
Swiss Federal Institute 
of Technology Zurich (ETH)
Sociology
ETH Zentrum SEW E 28
CH-8092 Zurich

Ben Jann, lic. rer. soc.
Tel. +41 1 632 55 58
Fax  +41 1 632 10 54
[email protected]
http://www.socio.ethz.ch/

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