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 <>
To   Roger Newson <>
Subject   Re: st: Stata 6 vs. 7
Date   Mon, 9 Sep 2002 22:31:29 +0800

Thanks for Roger's suggestion. Roger's suggestion is to wrap "myexpl"
in yet another calling program, which evaluates the vlist first to see
if it is empty. If it is empty, then no option will be passed to
"myexpl"; if it is a non-empty varlist, then an non-empty option
-myopt- is passed to "myexpl".

However, I am not sure whether it works for me. Because if there is a
vlist to be specified, I wish it is to be specified by the user in the
-myopt- option (or any other options, as long as they are "options").
Then the question loops back again: If vlist is desired to be empty,
then that wrapping program preceeds "myexpl" chokes when Stata 6 sees
it as empty.

Simply put, my problem is this: A (empty or non-empty) varlist needs to be
specified by an -option-, and so the -option- should be able to
accommodate both empty and non-empty varlist (for Stata 6).

Any other idea?


Monday, September 9, 2002, 1:38:00 AM, you wrote:

> At 15:22 07/09/02 -0700, HJW wrote:

>>    program define myexpl
>>      version 6.0
>>      syntax ...., ..... [myopt(varlist) .... ]
>>    end
>>In Stata 7, if I issue the command,
>>   myexpl ....., myopt()   /* empty in -myopt- */
>>then Stata will return empty for `myopt' in the program,
>>which is what I want.  However, if the same program runs
>>under Stata 6, then Stata complains with the message:
>>    myopt() is invalid

> In the calling program, you can define a local macro equal to 
> -myopt(varlist)- if the varlist is non-empty, and equal to an empty string 
> otherwise. For instance, if the varlist is in a macro -vlist-, then you 
> might have some lines, in your calling program, as follows:

> local myoptv ""
> if "`vlist'"!="" {
>    local myoptv "myopt(`vlist')"
> }
> myexpl,`myoptv'

> and -myexpl- will be called with the -myopt- option if, and only if, the 
> macro -vlist- is non-empty.

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index