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

Re: st: Stata 6 vs. 7


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   Re: st: Stata 6 vs. 7
Date   Tue, 10 Sep 2002 13:49:59 +0100

Hung-Jen Wang <[email protected]>

> Thank Weihua for the near-perfect solution to my problem arising
from
> running the codes in Stata 6 (executable). The only quirk left
though
> is that the program does not accept space as a legitimate empty
option
> value. That is, suppose I want the option value of -myopt- to be
> empty, myexpl, myopt()
>
> is fine, but
>         myexpl, myopt( )
>
> isn't (note the space in the option). Stata actually treats it as a
> non-empty option value, resulting in undesired parsing which returns
> ")" (no quotes) as the parsed value of -myopt-.
>
> To fix the small oddity, after
>
>        tokenize `myopt', parse("()")
>        local myopt `3'
>
> I can do the check again,
>
>       if "`myopt'" == ")"{
>          local myopt ""
>       }
>
> Or is there a more elegant solution? Including the space as a
parsing
> delimiter solves the problem but creates another, when non-empty
> varlist containing spaces between the variable names are specified
in
> myopt(..).

To echo and expand on my earlier posting in this thread,

program def myexpl
	version 6
	syntax [ , myopt(str) ]

	if trim("`myopt'") != "" {
		unab myopt : `myopt'
	}
	else local myopt

Nick
[email protected]

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