Dear All, consider the following example code:

Code:
clear all
version 16.0
program define foobar
   version 16.0
   syntax varlist , [count(integer 30) *]
   display `"`count'"'
   keep if (_n<`count')
   scatter `varlist', `options'
end

sysuse auto
foobar price weight, count(50.005) 
// end of file
Stata's documentation states literally the following
The macro contains the integer specified by the user, or else it contains the default value.
with regards to optional integer parameter. This explains why Stata
  • doesn't stop with an error on parsing the syntax (my preferred action);
  • doesn't round the value to e.g. 50 (agree, there could be different ways of rounding).
I have no problem with this. Yet I don't understand why Stata still keeps the option count() in the list of other options, which makes it stumble later on the scatter command. The logical way of handling this would have been to eliminate it from the `options' macro.

At this time I declare the option to be real, then confirm manually whether it is integer. This however defies the purpose of having the integer option declaration and is tedious in the case of many such integer options.

Is there any simple way to purge all so duplicated options from the `options' macro?

(Duplicated because the syntax appears to be something like :
Code:
foobar price weight, count(30) count(50.5)
where the first count() is used in the code of foobar and the second is passed to the scatter.

Interestingly, this behavior does not apply to integer numeric lists, where Stata happily stops with an error on encountering a non-integer value, such as in:
Code:
 syntax varlist , [count(numlist integer max=1) *]
yet I can't find a way to put a default value of the optional list into the syntax.

Thank you, Sergiy Radyakin