使用循環的 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 );
);