在Stata中执行if和else语句

时间:2013-10-08 19:42:50

标签: if-statement stata

当“md”“=”“lowess”时执行if和else语句。有谁能解释一下世界上这有可能吗?!

loc methods "connected lowess"

foreach md in `methods' {
if "`md'"=="lowess" {
    di "`md'==lowess"
}
else
{
    di "`md'!=lowess"
}
}   

输出结果为:

. do "/tmp/SD11749.000000"

. loc methods "connected lowess"

. 
. foreach md in `methods' {
  2.         if "`md'"=="lowess" {
  3.                 di "`md'==lowess"
  4.         }
  5.         else
  6.         {
  7.                 di "`md'!=lowess"
  8.         }
  9. }       
connected!=lowess
lowess==lowess
lowess!=lowess

1 个答案:

答案 0 :(得分:4)

您的else和后续{必须在同一行