按列屬性對列進行排序嗨 JMP 社區,
有沒有辦法按列屬性對列進行排序?
我有一個數據表,其中列包含屬性“測試編號”(見下文)。
我想按列屬性“測試編號”對列組“測試”中的所有列進行排序
我附上了下面的數據表。 有什麼建議麼?

謝謝,傑基!
自動化和腳本回复:按列屬性對列進行排序你好@傑基_ ,
我希望這樣的事情能滿足您的需求。 語法可能不正確,但思路是正確的。 我相信使用關聯數組是最簡單的方法,因為它會自動按固有的升序/字母順序對條目進行排序。
請注意,我已經離開group_tests_cols空的。 我看到您已將它們分組在“測試”中,因此您可能有一個列表,或一種檢索所有列名以創建列表的方法。
Names default to here(1);
dt = current data table();
group_tests_cols = { };
// automatically sorts key data in ascending / alphabetical order
aa_tests_cols = Associative Array();
// Puts all of the test numbers as the keys in the AA
for( a = 1, a <= N Items( group_tests_cols ), a++,
test_number = column( dt, group_tests_cols[a] ) << Get Property( "Formula" );
eval( eval expr( aa_tests_cols[ expr( test_number ) ] ) ) = group_tests_cols[a];
);
aa_keys = aa_tests_cols << Get keys;
// Moves columns in the order of the keys
for( b = 1, b <= N Items( aa_keys ), b++,<BR /> col_name = aa_tests_cols[ aa_keys[b] ]; // uses index of the key to retrieve the actual value of the key, to get the col name
eval( eval expr( expr( column( dt, col_name ) ) << Move Selected Columns( expr( { as column( col_name ) } ), after( :name ) ) ) );
);
回复:按列屬性對列進行排序這是一個工作腳本,它可以找到測試數值,然後根據它們對列進行排序。
Names Default To Here( 1 );
dt = Current Data Table();
//Get the test numbers and the column names associated with them
valList = {};
testList = {};
For Each( {col}, dt << get column group( "Tests" ),
Show( col );
Insert Into( valList, Num( col << get property( "Test Number" ) ) );
Insert Into( testList, Char( col << get name ) );
);
// Sort the test numbers
sortedList = Sort List( valList );
// Loop through the test orders and reorder the columns
For Each( {test, index}, sortedList,
theCol = Contains( valList, sortedList[N Items( sortedList ) + 1 - index] );
dt << go to( testList[theCol] );
dt << Move Selected Columns( To first );
);
其他人可能有更好的方法來完成這項任務
回复:按列屬性對列進行排序謝謝,吉姆!
回复:按列屬性對列進行排序我認為這適用於比 JMP17 更早的版本
Names Default To Here( 1 );
dt = Current Data Table();
aa = Associative Array();
For Each({col}, dt << get column group("Tests"),
aa[col << get name] = Num(col << get property("Test Number"));
);
Eval(EvalExpr(
dt << Move Selected Columns(Expr((aa << get keys)[Rank(aa << get values)]), To last)
));
在 JMP17(至少 JMP17.0)中,移動選定列的行為被更改(意外)知道為什麼 Move Selected Columns 與列表一起工作在 JMP17 中發生了變化嗎?
回复:按列屬性對列進行排序謝謝,亞爾莫!
回复:按列屬性對列進行排序@jthi我在 JMP 17 上,移動選擇不起作用。
多個移動選定列命令不會很穩健知道為什麼 JMP17 中的“移動選定列”適用於列表發生了變化嗎?
您可以為此建議的任何解決方法:
Names Default To Here( 1 );
dt = Current Data Table();
aa = Associative Array();
For Each({col}, dt << get column group("Tests"),
aa[col << get name] = Num(col << get property("Test Number"));
);
Eval(EvalExpr(
dt << Move Selected Columns(Expr((aa << get keys)[Rank(aa << get values)]), To last)
));
回复:按列屬性對列進行排序在循環內執行多次移動選定的列應該可行。 您只需首先創建列的排序列表,然後相應地循環