按列属性对列进行排序嗨 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)
));
回复:按列属性对列进行排序在循环内执行多次移动选定的列应该可行。 您只需首先创建列的排序列表,然后相应地循环