eblog 发表于 2010-1-20 14:58 
以下程序仅作例示:
program mytest
version 11
args l1 l2
sysuse auto,clear
replace price=`l1'+`l2'
end
运行之后,输入命令:
mytest 4 5
就把price变量值替换为9
问题:
如何在程序中控制这种情况,比如多输或少输入一个数字,如: “mytest 4 5 6” 、“mytest 4” 会提示错误!
cap program drop mytest
program mytest
version 11
args l1 l2
if `"`2'"' ==""{
dis as error "You must specify two arguments, not one!"
exit
}
if `"`3'"' !=""{
dis as error "You can not specify more than two arguments"
exit
}
sysuse auto,clear
replace price=`l1'+`l2'
end