Hi,
It seems I encountered an inconsistency between Stata 6 and
7, and I would like to ask for help. Say I have a program
like the follows.
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
I know Stata 6 probably expects variable names in -myopt-,
so when no name is given it complains. However, I need the
behavior of Stata 7; is there any way to let Stata 6 behaves
like its next generation does? Something like default=none
may do, but this does not seem to work on options. Can
anyone help? Thanks in advance.
[Just for those curious: I know his situation is odd,
because if an empty string is desired, why specify the
option -myopt- in the first place? Well, this is a part of a
complicated maximum likelihood program, which estimates
several different models. In order to preserve syntax
consistency across models, -myopt- is required if a
particular model is called, no matter whether it eventually
contains a varlist or an empty string. Alright, this may be
my own eccentric programing style, but please spare me with
the eccentricity.]
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: