回复:使用JSL选择动态行数,选择满足条件的行我尝试过这样的事情并出现错误在访问或评估“错误参数”时找不到列{1}
我想象的是内部的争论选择() 内加入() 。
我以为也许可以将列向量分配给变量,然后将该变量用作Select()中的参数。
// Get a list of the column names
colList = TRANSPOSE << Get Column Names();
// Starting with column 3, select
For(i=3,i<= N Cols( TRANSPOSE ), i++, COLUMN( TRANSPOSE , colList[i]) << Set Selected(1) ) ;
// Assign those selected columns to a variable
Select_cols = TRANSPOSE << Get Selected Columns();
//then feed that variable into the Select() withing Join()
<SPAN class="token comment">// JOIN</SPAN>
DT <SPAN class="token operator">=</SPAN> <SPAN class="token function">Data Table</SPAN><SPAN class="token punctuation">(</SPAN> TRANSPOSE <SPAN class="token punctuation">)</SPAN> <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Join</SPAN><SPAN class="token punctuation">(</SPAN>
With<SPAN class="token punctuation">(</SPAN> <SPAN class="token function">Data Table</SPAN><SPAN class="token punctuation">(</SPAN> CATEGORY_TABLE <SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
Select<SPAN class="token punctuation">(</SPAN> <SPAN class="token punctuation">:</SPAN>Forecast Material <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
SelectWith<SPAN class="token punctuation">(</SPAN> <SPAN class="token punctuation">:</SPAN>Category <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
Select<SPAN class="token punctuation">(</SPAN> Select_cols <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN> /// was Select<SPAN class="token punctuation">(</SPAN> <SPAN class="token punctuation">:</SPAN>Row <SPAN class="token number">1</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token punctuation">:</SPAN>Row <SPAN class="token number">2</SPAN> <SPAN class="token punctuation">)</SPAN>
By Matching Columns<SPAN class="token punctuation">(</SPAN> <SPAN class="token punctuation">:</SPAN>Label <SPAN class="token operator">=</SPAN> <SPAN class="token punctuation">:</SPAN>Category <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
Drop multiples<SPAN class="token punctuation">(</SPAN> <SPAN class="token number">0</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token number">0</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
Include Nonmatches<SPAN class="token punctuation">(</SPAN> <SPAN class="token number">0</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token number">0</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN>
Preserve main table order<SPAN class="token punctuation">(</SPAN> <SPAN class="token number">1</SPAN> <SPAN class="token punctuation">)</SPAN>
<SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
使用JSL选择动态的列数,选择满足条件的列https://www.jmp.com/support/help/14-2/use-set-selected-to-select-columns.shtml
重写这样的最佳方法是什么?
目的是DT是TRANSPOSE和CATEGORY_TABLE的联接。
- CATEGORY_TABLE是具有列Category的一列表
- TRANSPOSE是数据转置的结果
诀窍是TRANSPOSE的列数并不总是相同。 令人困惑的是,转置函数的输出将其他列命名为行1,行2等。
- TRANSPOSE的前两列始终相同。
- 列第1行将始终作为第3列存在。
- 第2行及以后的列可能会存在,具体取决于数据集。
我可以编写Select()函数的方式,使Join()至少选择第1行的列,然后再选择最后一列吗?
// This section is only build to handle two columns named Row 1 and Row 2
DT = Data Table( TRANSPOSE ) << Join(
With( Data Table( CATEGORY_TABLE ) ),
Select( :Forecast Material ),
SelectWith( :Category ),
Select( :Row 1, :Row 2 ), // sometimes there is only one row, sometimes there are more than one rows ******How to handle this?********
By Matching Columns( :Label = :Category ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 )
);
回复:使用JSL选择动态行数,选择满足条件的行删除其中带有“选择”的参数:
DT = Data Table( TRANSPOSE ) << Join(
With( Data Table( CATEGORY_TABLE ) ),
By Matching Columns( :Label = :Category ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 )
);
结果将包含两个表中的所有列。
回复:使用JSL选择动态行数,选择满足条件的行谢谢唐。我正在尝试更新其他人的代码。我认为这是我们想要的。在接受作为解决方案之前需要花费一些时间进行验证。不想让您认为我没有看到并感谢您的答复。昨天正在处理这个建议。谢谢!回复:使用JSL选择动态行数,选择满足条件的行谢谢BSwid。让我知道它是如何工作的。