Statalist


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

st: How to specify optional options and required options in a simple program


From   [email protected]
To   [email protected]
Subject   st: How to specify optional options and required options in a simple program
Date   Sun, 21 Oct 2007 16:32:40 -0300 (BRT)

Dear all,

("optional options" sounds funny, btw.)


Well, I have failed to write a program that can work with optinal options
as well as with required options. Consider a hypothetical example:

-----------------------------------------------------
capture program drop problem
program problem
version 10
syntax [varlist], a(integer) b(real) c(real) d(real) e(real) f(real) ///
		g(integer) h(integer) i(integer)
set obs `a'
gene B = `b'
gene C = `c'
gene D = `d'
gene E = `e'
gene F = `f'
gene G = `g'
gene H = `h'
gene I = `i'
end
----------------------------------------------------

typing

. problem, a(10) b(1.5) c(1.2) d(52.2) e(0.5) f(1.2) g(100) h(50) i(5)

-problem- works well.

However, if I want that option i be optional, that is:


-----------------------------------------------------
capture program drop problem
program problem
version 10
syntax [varlist], a(integer) b(real) c(real) d(real) e(real) f(real) ///
		g(integer) h(integer) [i(integer)]
set obs `a'
gene B = `b'
gene C = `c'
gene D = `d'
gene E = `e'
gene F = `f'
gene G = `g'
gene H = `h'
if `a'>=10 {
gene I = `i'
}
end
----------------------------------------------------


and typing again:

. problem, a(10) b(1.5) c(1.2) d(52.2) e(0.5) f(1.2) g(100) h(50) i(5)

The following error shows up:

invalid syntax
r(197);

Would it be possible to you to give me some clues about how to fix this?

All the best,

Tiago





*
*   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