你好,我想建立一個測試專欄:

來自以下腳本:
dt11 = current data table();<BR />
// Choisir colonnes commençant par employes
dur_cols = Filter Each( {col_name}, dt11 << Get Column Names( "String", Nominal ),
Starts With( col_name, "employes " )
);
// Nouvelle colonne
dt11 << New Column( "TEST EMPLOYES", Numeric, "Continuous", Format( "Best", 12 ) );
// Modifier la formule de colonne : TEST EMPLOYES
dt11:TEST EMPLOYES <<
Set Formula(
For( i = 1, i < n items(dur_cols), i++,
If(
(dur_cols[i] == dur_cols[i+1] | Is Missing( dur_cols[i+1] )),
:TEST EMPLOYES = 1
,
:TEST EMPLOYES = 0
)
)
);目標是根據 if 循環中的條件在測試員工列中擁有 0 或 1......目前我無法建立值為 0 或 1 的測試員工列。
感謝您的協助
我從一個員工列開始,其中填寫了幾個字段,例如“611 - 2000 - 300”,可以填寫3個以上的字段。
在我的腳本中,我用“-”分隔符號分割了這一列,因此“employe...”列的數量與第一個“employe”列中的字段數量一樣多。
條件測試員工 = 1:
所有建立的員工列都相等或缺少值
條件測試員工 = 0:
在員工列中建立不同的資料(當列為空時不考慮)
範例 1:
員工欄 1:300
員工列 2:300
員工第 3 欄:500
測試員工 = 0
範例 2:
員工欄 1:300
員工列 2:300
員工列 3:
測試員工 = 1
從原始列進行計算可能更容易
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(3),
Compress File When Saved(1),
New Column("Column",
Character,
"Nominal",
Set Values({"1-1-3", "2-2-2", "3-3", ""})
),
New Column("Column 1", Character, "Nominal", Set Values({"1", "2", "3", ""})),
New Column("Column 2", Character, "Nominal", Set Values({"1", "2", "3", ""})),
New Column("Column 3", Character, "Nominal", Set Values({"3", "2", "", ""}))
);
dt << New Column("R", Numeric, Nominal, Formula(
res = Associative Array(Words(:Column , "-")) << get keys;
Remove From(res, Contains(res, "")); // remove missing value
N Items(res) == 1;
));

不確定應該如何充分考慮缺失行,在這種情況下它被視為 0,但可以將其更改為修改最終比較的 1