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
The macro contains the integer specified by the user, or else it contains the default value.
- 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).
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)
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) *]
Thank you, Sergiy Radyakin
0 Response to Options parsing in syntax
Post a Comment