Statalist


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

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


From   "Le Wang" <[email protected]>
To   [email protected]
Subject   st: Programming advice on specifying a sample-specific default value
Date   Mon, 31 Mar 2008 23:01:58 -0500

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/



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