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

Re: st: Stata 6 vs. 7


From   Hung-Jen Wang <hjwang@econ.sinica.edu.tw>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Stata 6 vs. 7
Date   Tue, 10 Sep 2002 20:25:56 +0800

Tuesday, September 10, 2002, 1:30:16 AM, you wrote:

> --Hung-Jen Wang <hjwang@econ.sinica.edu.tw> wrote:

> To work around the problem, Hung-Jen may try -myopt(passthru)-.  See the
> following example:

>         program define myexpl
>                 version 6
>                 syntax [, myopt(passthru)]
>                 if "`myopt'" != "" {
>                         di "myopt is: `myopt'"
>                         tokenize `myopt', parse("()")
>                         local myopt `3'
>                         summ `myopt'
>                 }
>                 else {
>                         di "myopt() is empty"
>                 }
>         end

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(..).

HJW

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