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

Re: st: What's wrong with -syntax, [now]-?


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: What's wrong with -syntax, [now]-?
Date   Wed, 22 Jun 2005 14:43:00 -0500

At 02:47 PM 6/22/2005 -0400, Chris Ruebeck wrote:
This post seems trivial, but the issue did cost me some non-trivial debugging time.

It seems that an option named "now" won't work. It can't be that option names must have more than three characters, because an option named "yes" works. I used -search now- to see if it's a reserved word, but got no hits. Although -findit now- is an amusing command to issue, it's also not surprising that too many results are returned to be useful for investigation of this minor annoyance.

Eureka (just as I was composing the subject for this post)! I'll continue to post it anyway for the interest of the non-gurus on the list. It's the fact that "now" begins with "no". See /optionally_off/ in -help syntax-.

Chris


. program define junk
1. syntax , [now]
2. di "`now'"
3. end

. junk, now
Actually, you can have an option called "now" BUT you have to start it with one or more capital letters in the syntax command, e.g.

. program define junk
1. syntax, [Now]
2. di "`now'"
3. end

. junk, now
now

Which can also be executed this way:

. junk, n
now


Also, what you've actually got in your original program is a local macro called "w". So,

. program drop junk

. program define junk
1. syntax, [now]
2. di "`w'"
3. end

. junk, now
now

I find the "no" coding confusing so I try to avoid it - and it is easy to make mistakes if you are not careful or do not know about it.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

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