我有一张包含几百列的数据表。我希望能够搜索所有列公式,以查看某一列是否在任何列公式中使用。这可能吗?
是的......
Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "/C:/Program Files/JMP/JMPPRO/19/Samples/Data/Big Class.jmp" );
dt << new column("Ratio", formula(:height/:weight));
theFormula = Char(dt:Ratio << get formula);
If( contains(theFormula, "height"), show("found it"));如果您可以访问 JMP Pro,您可以使用 Formula Depot 执行此操作。

您可以选择公式列,选择复制列,打开新脚本(ctrl + t)并粘贴到那里。然后在脚本编辑器中搜索。
您也可以尝试删除该列,如果该列正在使用,JMP 将显示类似以下警告:

编辑:
JMP18 中可能也有一些利用列管理器的方法,但我能想出一个。数据字典几乎可以做到这一点,但它将公式存储为图像,因此无法轻松搜索

当然还有很多纯脚本选项
吉姆,
谢谢。由于我现在写脚本的水平真的很差,您能向我演示如何让您的算法循环遍历数据表中的所有列并输出包含目标值的列的列表吗?
雅尔莫,
不幸的是,我没有 JMP Pro。出于某种原因,当我尝试删除列时收到的错误消息没有列出包含公式的列。我不知道为什么。我还以为数据字典可能会有所帮助,但我看了之后不知道它有什么用。不过还是谢谢你的帮助。
我还分享了另一个不依赖于 JMP Pro 的选项
您可以选择公式列,选择复制列,打开新脚本(ctrl + t)并粘贴到那里。然后在脚本编辑器中搜索。


哦……太酷了。我不知道你可以将列粘贴到脚本编辑器中。
我认为这会起作用。
谢谢!
与@jthi复制每列脚本的建议类似,您可以使用红色三角形(表格左上角)> 复制表脚本(无数据)复制不包含数据的整个表格的脚本。

该脚本将包含用于重新创建表格的 jsl,其中将包括所有列公式。将该脚本粘贴到脚本窗口中,然后从那里进行搜索。
我希望这有帮助!
@朱利安
@julian也许这种类型的搜索可以在某些功能中实现到列管理器中?因此,我们还可以搜索列属性中的值,而不仅仅是筛选出具有特定属性的值。至少公式、注释和短/长列名称是少数几个可能对我们有帮助的列属性,如果我们可以从中进行搜索的话。
我首先从@julian的想法开始使用表格脚本,并添加了一些功能
- 在公式中搜索列并
- 显示搜索结果:
//Open( "$SAMPLE_DATA/Ship Damage.jmp" );
// get all column formulas via the table script
dt = Current Data Table();
dt << copy table script( "No Data" );
script = Parse( Get Clipboard() );
//convert to List for easier indexing
Substitute Into( script, Expr( New Table() ), Expr( {} ) );
// just keep the columns
allCols = Filter Each( {col}, script, Head( col ) == Expr( New Column() ) );
// convert column info into lists
ColList = Transform Each( {col}, allCols, Substitute( Name Expr( col ), Expr( New Column() ), Expr( {} ) ) );
allColNames = Transform Each( {col}, ColList, tmp = Arg( col, 1 ); If (is string(tmp), tmp, tmp["en"]) );
// keep columns with formulas
ColsWithFormulas = Filter Each( {col}, ColList,Try(col["Formula"]; 1 , 0 ));
ColNames = Transform Each( {col}, ColsWithFormulas, tmp = Arg( col, 1 ); If (is string(tmp), tmp, tmp["en"]) );
ColFormulas = Transform Each( {col}, ColsWithFormulas, col["Formula"] );
// helper function to search for column names in formulas
ContainsExpr = Function( {expression, pattern},
tmp = Substitute( Name Expr( expression ), Name Expr( pattern ), Expr( . ) );
Not( Name Expr( tmp ) == Name Expr( expression ) );
);
summary = New Table("Formuala Overview",
New Column( "column Formula", Character ),
New Column( "used cols", Character ),
);
wait(0);
// fill the summary tale with all combinations of formulas and the used columns
Current Data Table( dt ); // make dt the current data table, otherwise <AS column=""> won't work !
For Each( {myFormula, idx1}, ColFormulas,
For Each( {col}, allColNames,
formulaCol = ColNames[idx1];
dt:formulaCol << Set Header Text Color( "Red" );
If( ContainsExpr( Name Expr( myFormula ), Name Expr( As Column( col ) ) ),
Eval( Eval Expr( summary << add row( {"column Formula"n =Expr(formulaCol ), "used cols"n = Expr( col )} ) ) );
Column(col) << Set Header Background Color( {102, 255, 140} );
)
)
);
// show a tabulate for easy look up
summary << Tabulate(
Show Control Panel( 0 ),
Add Table( Row Table( Grouping Columns( :column Formula, :used cols ) ) ),
Local Data Filter( Mode( Show( 0 ) ), Add Filter( columns( :column Formula, :used cols ) ) )
);</AS>除了通过列背景颜色突出显示公式中使用的列的方法之外,
有人可能会考虑为公式中使用的列添加指示符号