帮助使用 if 语句你好,
我可能在这里遗漏了一些基本的东西。 我正在尝试通过使用其他两个列值的组合来更改列的值。 我输入以下 if 语句并且列值不会更改。 我在这里缺少什么? 感谢您的任何提示和建议。
Names Default To Here( 1 );
dt = Data Table( "20210811Miflezet_CAPCMP.jmp" );
dt << Begin Data Update;
If( :justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "center"
,
:Rile_Calc3 == "center"
,
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "center"
,
:Rile_Calc3 == "center"
,
:justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "left"
,
:Rile_Calc3 == "right"
,
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "left"
,
:Rile_Calc3 == "left"
,
:justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "right"
,
:Rile_Calc3 == "left"
,
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "right"
,
:Rile_Calc3 == "right"
);
dt << End Data Update;
数据表脚本编写回复:帮助 if 语句您可以使用 For Each Row 或 Set Each Value。 下面是一个例子:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
For Each Row(
If(:sex == "F",
:age = .
);
);
dt:weight << Set Each Value(
If(:sex == "M",
.,
:height
);
);回复:帮助 if 语句感谢你的回答! 正如各种脚本指南所示,它应该是正确的,但它在这里不起作用。 我假设数据表和我已经对这些变量所做的所有处理有问题。 最终,解决方法是将两个名义列连接为一个,然后将我得到的表达式重新编码为所需的结果。 再次感谢。
回复:帮助 if 语句在您的原始 JSL 中,您可能(编辑:也)想要更改
Rile_Calc3 == "center" // compare. the result of the compare (0 or 1) will be the result of the if(), see below
到
Rile_Calc3 = "center" // assign value
JSL if 语句返回一个值;你可以把它写成
:Rile_Calc3 = If(
:justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "center", "center",
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "center", "center",
:justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "left", "right",
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "left", "left",
:justice_decision_REC_RILE2 == "reject" & :RILE_Calc2a == "right", "left",
:justice_decision_REC_RILE2 == "accept" & :RILE_Calc2a == "right", "right",
:Rile_Calc3 // or "Unknown" ? depends how you want to handle the unexpected case.
);
如果您知道没有意外情况,则可以省略最后的 else 子句。 但是意外情况的本质是在最意想不到的时候出现。
如果秘密