你好
我正在尝试将列中值为“拒绝吗?”的行中的所有数据子集化为名为拒绝的新表
我尝试了几种方法,但都不起作用,并且出现错误:
“意外的“Split_dt”。可能缺少“;”或“,”。
第 77 行第 1 列:►Split_dt << 选择 Where(:is rejection? == "Y" );”
此代码是创建列“是否拒绝?”的更大脚本的一部分。
当我运行所有脚本时出现上述错误,但当我单独运行它时它可以正常工作。
我该怎么做才能修复它?
选项1:
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
选项2:
Split_dt << Select Where(:is rejects? == "Y");
rejects = Split_dt << Subset(Output Table Name("rejects"), All Columns);
完整脚本:
Split_dt = Current Data Table();
Split_dt << New Column("is rejects?", character, Formula("N"));
Column(Split_dt, "is rejects?") << Delete Formula;
// Get the number of columns in the data table
numCols = N Cols(Split_dt);
// Iterate over each row in the data table
For Each Row(
// Iterate over each column starting from column 6
For(colIndex = 6, colIndex <= numCols, colIndex++,
// Get the column reference
currentCol = Column(Split_dt, colIndex);
// Check if the value in the current cell is greater than 100 and "is rejects?" is "N"
If(
currentCol[] > 100 & :is rejects? == "N" & Contains(currentCol << Get Name, "BI")
== 0,
// Change the value in the "is rejects?" column to "Y"
:is rejects? = "Y";
// Exit the loop early since we only need one match
Break();
);
)
);
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
我通常在对特定行进行子集设置时使用 Rows()(您也可以对选定的行进行子集设置,但通常这样做最终会在表中执行不必要的选择)。
此示例将对 sex ==“F” 的所有行进行子集化
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
rows_to_subset = dt << get rows where(:sex == "F");
dt_subset = dt << Subset(Rows(rows_to_subset), Output Table("Subset F"));感谢您的快速回复。
您建议的解决方案给出了同样的错误:(
您使用的是哪个 JMP 版本?您尝试过我的示例脚本吗?
尝试
rejects = Split_dt << Subset(
Filtered Rows(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);