JSL脚本大家好,
我对JMP和编写JSL脚本完全陌生,我需要帮助来构建案例逻辑:
我有一个表,其中一列为Status,我想在其中计算1的数量。它将在看到第一个“ 1”时开始计数,并继续计数直到最后一个,并在最后一次出现1时输出最终计数。并且在下一行看到“ 0”后,应再次重置计数器并开始寻找“ 1”。

如果您能帮助我,我将不胜感激。
阿比
回复:JSL脚本可以做到这一点
Names default to here(1);
m = [0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0];
dt = new table("Test",
<< New Column("Status", <<SET values=""></SET>回复:JSL脚本names default to here(1);
// create the table
m = [0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0];
dt = new table("Test",
new column("Status", set values(m));
);
// create the empty status column
dt << new column("Output");
// iterate over each row of the table
result = 0; // counter for consecutive 1's
for (i=1,i<=nrows(dt),i++,
// apply the logic the way
// that you would think it
value = dt:Status[i]; // i'th row of Status column table referenced by dt
if (value==0,
dt:Output[i] = 0;
result = 0;
,
result = result + 1;
dt:Output[i] = result;
)
);回复:JSL脚本感谢您的帮助。逻辑非常简单明了,对您有很大帮助。再次感谢。