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

st: RE: ... and you can quote me


From   "David E Moore" <[email protected]>
To   [email protected]
Subject   st: RE: ... and you can quote me
Date   Wed, 24 Sep 2003 14:56:04 -0700

You might want to save a little less typing in queries to Statalist, but on the
assumption that I know what you want to achieve, you might try something like:

local 1 whatever
local if `1' == "first thing" | `1' == "second thing"
if `if' { display "Gotcha!" }
else { display "Rats!" }

That doesn't seem too complicated, so perhaps you're wanting something else,
such as a way to delay the substitution of local macros (i.e., store the quoting
characters "`" and "'" in a macro definition).  That's a lot more difficult, but
I was able to do it by creating macros for the quote characters and plugging
those in where I would ordinarily use the quotes.  For example:

local lquote ``'
local rquote `''
local if `lquote'1`rquote' == "first thing" | `lquote'1`rquote' == "second
thing"

To get double indirection, you simply stack the quote macros.  Again, it isn't
clear to me what you're ultimately trying to accomplish.

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of NBER Test
> Sent: Wednesday, September 24, 2003 11:03 AM
> To: [email protected]
> Subject: st: ... and you can quote me
>
>
> I'd like to save typing and clean up a program by
> using
> a local variable with conditions that evaluate strings
> like below:
>
> local 1 "whatever"
> local if "``1' == "first thing" | `1' == "second
> thing"'"
> if `if' { ...
>
> only I can't get the quotes or compound quotes in my
> `if' declaration to resolve quite right.
>
> Thanks for your help!
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> *
> *   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/
>
>

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