对多列中的多个值进行重新编码JMP 专家您好,
我正在对数据表中的 103 列数据进行重新编码。 每列中都需要进行相当多的重新编码。 我试图关注这篇文章:
https://community.jmp.com/t5/Discussions/Recode-multiple-columns-with-JSL-script/mp/7865#M7859
但使用重新编码而不是“if”。
我认为我的问题出在我使用的“cols”上。 我不确定如何引用我所定位的列,并通过“for”内的每个循环从一列移动到下一列。
感谢您的帮助!
cols = dtconcat << get column names;
For Each Row( For(i=1, i<=N Items(cols), i++,
cols(i) = Match( cols(i),
"NQ", "0",
"Nq", "0",
"NA", ".",
"N/A", ".",
">30", "30",
">20", "20",
"<5", "0",
"<2.00", "0",
"<2.0", "0",
"<2", "0",
"<1", "0",
"<0.5", "0",
"<0.01", "0",
"#N/A", ".",
"-", ".",
cols(i))
)
);
回复:重新编码多列中的多个值非常感谢!回复:重新编码多列中的多个值你有 2 个问题。
- 使用下标的正确语法是将其括在“[ ]”而不是“( )”中。
- 您需要告诉 JMP Cols[i] 将用作列引用
请参阅下面更正后的脚本
cols = dtconcat << get column names;
For Each Row(
For( i = 1, i <= N Items( cols ), i++,
As Column( cols[i] ) =
Match( As Column( cols[i] ),
"NQ", "0",
"Nq", "0",
"NA", ".",
"N/A", ".",
">30", "30",
">20", "20",
"<5", "0",
"<2.00", "0",
"<2.0", "0",
"<2", "0",
"<1", "0",
"<0.5", "0",
"<0.01", "0",
"#N/A", ".",
"-", "."
)
)
);