幫助使用 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 子句。 但意外情況的本質是在最意想不到的時候出現。
如果秘密