Bookmark and Share

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]

st: RE: RE: RE: literal single quotes


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: literal single quotes
Date   Thu, 4 Mar 2010 18:05:17 -0000

No one suggested the first. `= char(96)' is needed 

On the general idea, I happily accept that programmers want to avoid
ugly codes. But I have never found this device either necessary or
attractive. The underlying idea seems to be that of "storing" the macro
for later use, but you really don't need to code like that. 

Nick 
[email protected] 

Feiveson, Alan H. (JSC-SK311)

Thanks, Roger, Nick

Both suggestions work, but something like

. local bull =  "count if char(96)tempchar(39) >0"
. `bull'

unknown function ()
r(133);


does not work.




. local lq = char(96)

. local rq = char(39)

. local bull =  "count if `lq'temp`rq'  >0"

. `bull'
  334

(works)

. local bull   "count if  \`temp\'  >0"

. `bull'
  334

(works)


Nick - I see a legitimate need for this when you have a long expression
involving temporary variables or names that may make the code look ugly
if written out next to some other long statement.

Nick Cox

This sounds like the urge for setting up a delayed evaluation, on which
my advice is 

1. Use \` to insert a literal left quote if the urge is overwhelming. 

2. Better, resist the urge. Rewrite your code so that you don't need to
do it.  

This came up a few months ago, but I can't find my post. Martin Weiss
will probably remember it. 

Nick 
[email protected] 

Feiveson, Alan H. (JSC-SK311)

Can someone please tell me how to define a local macro  that contains
literal single quotes? For example Suppose I want to do something like

local bull "count if `temp' > 0"

where `temp' is to be interpreted literally, not evaluated.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index