[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"David Moore" <davem@hartman-group.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
RE: st: Stata 6 vs. 7 |

Date |
Mon, 9 Sep 2002 10:05:07 -0700 |

You could pass an empty string (i.e., myopt("")) as the parameter value. I haven't tested this with Version 7 of Stata, so it might not work as a general approach. Of course, this would introduce another "eccentricity" in that the user would actually have to enter the quotes. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Hung-Jen Wang Sent: Monday, September 09, 2002 7:31 AM To: Roger Newson Subject: Re: st: Stata 6 vs. 7 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? HJW 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: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * 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/

**References**:**Re: st: Stata 6 vs. 7***From:*Hung-Jen Wang <hjwang@econ.sinica.edu.tw>

- Prev by Date:
**st: RE: RE: distribution of the kernel density** - Next by Date:
**RE: st: loop thru unique values of a variable** - Previous by thread:
**Re: st: Stata 6 vs. 7** - Next by thread:
**RE: st: Stata 6 vs. 7** - Index(es):

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