stata的说法:anything is for use when you want the command to have the nearly standard syntax of command name followed by something followed by if, in, options, etc. For instance, perhaps the command is to be followed by an expression or expressions, or a list of numbers.
syntax anything
foreach x in `anything' {
qui cap assert sqrt(abs(`x'))!=.
if _rc {
di as text _n "The input " as result "`x'" as text " not be numeric! try again please! "
exit
}
}
eblog 发表于 2010-2-1 12:09 以下代码应该可以比较方便的控制参数为numeric:
syntax anything
foreach x in `anything' {
qui cap assert sqrt(abs(`x'))!=.
if _rc {
di as text _n "The input " as result "`x'" as text " not be numeric! try again please! "
exit
}
}
……
syntax anything
if indexnot("`anything'"," 0123456789"){
di as error "Only 0-9 and space can be input"
exit
}
……
eblog 发表于 2010-2-1 12:09 以下代码应该可以比较方便的控制参数为numeric:
syntax anything
foreach x in `anything' {
qui cap assert sqrt(abs(`x'))!=.
if _rc {
di as text _n "The input " as result "`x'" as text " not be numeric! try again please! "
exit
}
}
……
syntax anything
if indexnot("`anything'"," 0123456789"){
di as error "Only 0-9 and space can be input"
exit
}
……