If-then-else匹配问题

时间:2015-01-20 14:40:16

标签: if-statement sas

运行此代码时出现错误

  

没有匹配的if-then子句

if x=1 then do;
if diff>12 and (8<=p<=12 or 3<=p<5) then g=1;
else if (1<=p<=2) then g=2;
else g=3;
end;

请帮助我理解我的错误?

1 个答案:

答案 0 :(得分:0)

我复制了您的代码并运行了以下内容:

data test;
x = 1;
diff = 14;
p=14;

if x=1 then do;
   if diff>12 and (8<=p<=12 or 3<=p<5) then g=1;
   else if (1<=p<=2) then g=2;
   else g=3;
end;
run;

似乎有什么问题?确保定义了x,diff和p。

相关问题