你好
在我的表格中,我有 3 列:時間、實驗室數據和一個溫度。
對於實驗室數據,我想只保留可用的值,並將所有連續行設置為空,直到我們有新的實驗室結果。
我應該如何編寫腳本來處理這個?
謝謝

除了 DS 的公式解決方案之外,您還可以如下所示進行處理。
首先,我們需要按年齡對 Big Class 進行排序(這是您的實驗室數據)。
我們選擇列年齡並讓 jmp 查找年齡的所有重複行。
對於這些我們刪除年齡值。
喬治
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << sort( by( age, name ), Replace Table );
dt << select columns(age);
dt << select duplicate rows();
dt:age[dt << get selected rows()]=.;
幾個額外的公式選項(如果需要,只需使用替換 << 將每個值設置為公式)
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(9),
New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 1, 2, 2, 2, 3, 3, 3])),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([1.2, 1.2, 1.3, 2.3, 2.4, 2.1, 3.5, 3.6, 3.1]))
);
dt << New Column("Result", Numeric, Continuous, << Set Each Value(
IfMZ(:Dif(:Column 1) == 0,
.
,
:Column 1
)
));
dt << New Column("Result2", Numeric, Continuous, << Set Each Value(
If(Row() == Col Min(Row(), :Column 1),
:Column 1
,
.
);
));你好@LogitTurtle576 ,
一種可能的方法是使用以下公式生成一個新列:
If(
:Column 1 == Lag(:Column 1, 1), .,
Row() == 1, :Column 1[1],
:Column 1[Row()]
)
其中 :Column 1 是您感興趣的數據列。 這會將所有值設置為 null,除非從一行更改為下一行,否則它將使用該值。 中間條件將第一行設置為數據列第 1 行的值。
我敢肯定還有其他方法,但我知道這個可以做你感興趣的事情。 另外,由於您有另一列,因此您不會因重新編碼或覆蓋原始列而丟失任何原始數據。
希望這可以幫助!,
DS