Paul,
Many thanks. I appreciate this. It works well!
Le
On Tue, Apr 1, 2008 at 1:09 AM, Paul Millar <[email protected]> wrote:
> Hi Le,
>
> Try this:
>
> program example
> version 10
> syntax varlist(max=2) [if] [in] [, option1(numlist max=1)]
>
> gettoken y 0: 0
> gettoken x 0: 0
> if "`option1'" == "" {
> local option1=sum(y)/sum(x)
> }
> di "option1=`option1'"
> end
>
> example x y
> example x y, option1(44)
>
> - Paul
>
>
>
> At 01:28 AM 01/04/2008, you wrote:
> >Thanks Paul.
> >
> >I thought about using some arbitrarily large number earlier. But I
> >recently came across an example, in which case the specified value is
> >indeed that large..So, I was wondering if there is any better
> >alternative.
> >
> >Le
> >
> >On Tue, Apr 1, 2008 at 12:12 AM, Paul Millar <[email protected]> wrote:
> > > How about something like:
> > >
> > > program define example,rclass
> > > syntax varlist(max=2) [if] [in] [, option1(real -999)]
> > >
> > > gettoken y 0: 0
> > > gettoken x 0: 0
> > >
> > > if `option1' == -999 {
> > >
> > > local option1=sum(y)/sum(x)
> > > }
> > >
> > >
> > >
> > > At 12:01 AM 01/04/2008, you wrote:
> > > >Hi there,
> > > >
> > > >Thanks in advance for your time.
> > > >
> > > >I am programming a ado file which needs to calculate a sample-specific
> > > >default value (according to some formulae), when the user does not
> > > >specify the option. I am not quite sure how I should use the -syntax-
> > > >to do this because -syntax- requires a fixed default value.
> > > >
> > > >For example, - example - won't work.
> > > >
> > > >program define example,rclass
> > > > syntax varlist(max=2) [if] [in] [, option1(real)]
> > > > gettoken y 0: 0
> > > > gettoken x 0: 0
> > > >
> > > > if "`option1'" == ""{
> > > > local option1=sum(y)/sum(x)
> > > > }
> > > >end
> > > >
> > > >But how can I get around with this? Thank you very much.
> > > >
> > > >Le
> > > >--
> > > >~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >Le Wang, Ph.D.
> > > >Minnesota Population Center
> > > >University of Minnesota
> > > >(o) 612-624-5818
> > > >*
> > > >* 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/
> > >
> >
> >
> >
> >--
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >Le Wang, Ph.D.
> >Minnesota Population Center
> >University of Minnesota
> >(o) 612-624-5818
> >*
> >* 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/
>
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Le Wang, Ph.D.
Minnesota Population Center
University of Minnesota
(o) 612-624-5818
*
* 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/