回复:使用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。讓我知道它是如何工作的。