Statalist


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

Re: st: Programming advice on specifying a sample-specific default value


From   Paul Millar <[email protected]>
To   [email protected]
Subject   Re: st: Programming advice on specifying a sample-specific default value
Date   Tue, 01 Apr 2008 01:12:34 -0400

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/



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