使用循环的 JSL 脚本和摘要需要有关如何使此循环工作的任何建议:itt 在 Group( Box(i) ) 行中不断打嗝,我认为这是数字或括号/不正确的列名称的问题。但调整这些并没有帮助
For( j = 1, j < 3, j++,
nrj j = dt1 << Summary(
Group( Box( i ) ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 ),
output table name( "Sum " || Char( j ) )
)
);
数据存取数据混合和清理回复:使用循环的 JSL 脚本和摘要我创建了一个数据表,其中有一列名为“地点 ID”。我用 100 个范围从 1 到 850 的随机值填充它。

然后我运行了不同 Box 和 ActualLoc 的代码部分,它创建了一个如下所示的数据表:

我没有看到执行这些操作的意图。
在我看来(我很容易错),您不了解您正在使用的某些元素。在第一个 For() 循环中,您创建了相同的 Scenario、Box 和 ActualLoc 列 5 次。由于 JMP 不允许列具有相同的名称,因此当您在第一个循环期间创建 Scenario、Box 和 ActualLoc 时,这些是它将使用的实际名称。但是,在循环 2 上,JMP 将强制使用方案 2、框 2 和 ActualLoc 2 的名称。循环 3、4 和 5 重复此行为。使用的公式也有点令人困惑。您重复使用了(:地点 ID - i)的规范。由于这是在公式中使用的,这意味着该公式将应用于数据表中的每一行,并且此计算的结果将是给定行(即我的行 1 中的第 1 行)的变量 Place ID 的值。数据表的值为 268),它会减去 i 的当前值,第一个循环的值为 1,第二个循环的值为 2,依此类推。因此,对于第 1 行,值的范围是 267 到 263 。我怀疑您可能认为 :Place ID -1 正在引用 :Place ID 之前的列。
您能否帮我解决一下,并澄清您尝试对数据表中的“地点 ID”列执行什么操作?
回复:使用循环的 JSL 脚本和摘要MMMM 我不确定...我的剧本技巧很差。 这是我的整个代码。 它可以正常运行到带有摘要步骤的循环部分。
t1 = Open( "C:\Users\ClaireR\Desktop\Example\ExampleABC.jmp" );
For( i = 1, i <= 5, i++,
dt1 << New Column( "Scenario", Numeric, "Continuous", Formula( :Place ID - i ) );
dt1 << New Column( "Box",
Character,
"Nominal",
Formula(
If( (:Place ID - i) <= 200,
"Ground",
If( (:Place ID - i) <= 250,
"Drop 1",
If( (:Place ID - i) <= 400,
"Ground",
If( (:Place ID - i) <= 450,
"Drop 2",
If( (:Place ID - i) <= 600,
"Ground",
If( (:Place ID - i) <= 650,
"Drop 3",
If( (:Place ID - i) <= 800,
"Ground",
If( (:Place ID - i) <= 850,
"Drop 4",
"Ground"
)
)
)
)
)
)
)
)
)
);
dt1 << New Column( "ActualLoc",
Character,
"Nominal",
Formula(
If( (:Place ID - i) <= 200,
"Ground",
If( (:Place ID - i) <= 250,
:Place ID 2,
If( (:Place ID - i) <= 400,
"Ground",
If( (:Place ID - i) <= 450,
:Place ID 2,
If( (:Place ID - i) <= 600,
"Ground",
If( (:Place ID - i) <= 650,
:Place ID 2,
If( (:Place ID - i) <= 800,
"Ground",
If( (:Place ID - i) <= 850,
:Place ID 2,
"Ground"
)
)
)
)
)
)
)
)
)
);
);
:Scenario << Set Name( "Scenario 1" );
:Box << Set Name( "Box 1" );
:ActualLoc << Set Name( "ActualLoc" );
mrj = {};
For( j = 1, j < 3, j++,
newDT = dt1 << Summary(
Group( Box[j] ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 ),
output table name( "Sum " || Char( j ) )
);
Insert Into( mrj, newDT );
);
回复:使用循环的 JSL 脚本和摘要我假设 Box 引用了一个名为 Box 的内存变量,它是一个列表,包含多个元素,每个元素都是一个变量的名称。 如果不是这个,那么 Box 是什么?回复:使用循环的 JSL 脚本和摘要谢谢吉姆。
我理解需要添加列表变量和拼写错误。但是,当我更新代码并运行它时,我收到此错误。 我的列名称是“Box 1”。 “盒子2”等
不过,我确实尝试将列名称更改为 Box1 、 Box 2 和 Box3 等,但出现了相同的错误。有什么建议么?

回复:使用循环的 JSL 脚本和摘要// I am assuming that your syntax of
// nrj j = dt1 << Summary(
// was an attempt to create a pointer to each new data table
// being created in the Loop, one for each column in the list
// of columns called "Box"
// To do that, one needs to create a new List variable, and then
// populate the list by inserting the new data table reference
// by using an "Insert Into()" on each loop
// Create a list variable to hold the data table references
mrj = {};
For( j = 1, j < 3, j++,
newDT = dt1 << Summary(
// Your reference to the list variable called "Box"
// Group( Box(i) ),
// incorrect for 2 reasons. 1. When referencing a
// subscript, it is done using square brackets [ ],
// 2. the index variable you are specifying is "i",
// while the index variable for your For() loop is
// a the variable "j"
Group( Box[j] ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 ),
output table name( "Sum " || Char( j ) )
);
Insert Into( mrj, newDT );
);