Statalist


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

RE: st: Re: How to eliminate the double quotes surrounding letters?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Re: How to eliminate the double quotes surrounding letters?
Date   Sat, 29 Aug 2009 17:09:20 +0100

That is the wrong way to think about the double quotes. 

In "ab cd ef" the " " are delimiters, showing where the string begins
and ends: they are not part of the string, just as an envelope is not
part of a letter. 

Why do you need the delimiters in Stata? One good reason, which is quite
sufficient, is that if you refer to 

ab cd ef 

then in many Stata contexts it is expected that such strings are
variable names (or scalar names). You need the " " in "ab cd ef" to make
it clear whenever you have a literal string, not names of variables or
scalars. 

In general, Stata automatically sees the delimiters and strips them off.
You need do nothing to ensure that. Consider 

. di "ab cd ef" 

ab cd ef 

-display- strips the delimiters. Also consider what happens you go 

local foo = subinstr("Stata is good", "good", "excellent", .) 

The local -foo- ends up containing 

Stata is excellent

If you in turn need to refer to that local, then you will need to refer
to  "`foo'" to make clear that a literal string is required -- unless
you do have actually have variable names -Stata-, -is-, -excellent-! 

Nick 
[email protected] 

[email protected]

Joseph,

thank you very much for your help and I solved my problem by the method
you suggested.
By the way, is it a general way to deal with eliminating double quotes
surrounding letters?
Namely, is there a function applied in this situation? I tried -real()-
function, however, I got a missing value.


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index