回复:無需輔助列就可以直接獲取匹配數據嗎?我不確定我是否完全了解您要做什麼。作為一個具體示例,您是否要確定數據表中13歲男性的人數並將其放入一列,而不創建年齡和性別串聯列?如果那是您想要的,我認為此公式列將起作用:

請注意,此公式僅計算數據表中非缺失條目的數量。在這種情況下,我選擇按年齡和性別來計算“名稱”列中不丟失條目的數量。不需要中間列或新表。
回复:無需輔助列就可以直接獲取匹配數據嗎?我尚未測試此代碼,但是您至少應該看到我採用的方法,並且該方法可以工作。
Names Default To Here( 1 );
dtBig = Data Table( "Big Class" );
dtSmall = Data Table( "Big Class By (age, sex)" );
dt << New Column( "N Rows" );
For( i = 1, i <= N Rows( dtSmall ), i++,
foundRows = dtBig << get rows where(
Substr( :agesex[i], 1, Length( :agesex[i] ) - 1 ) == :age & Substr( agesex[i], -1 ) == :sex
);
If( N Rows( foundRows ) > 0,
dtBig:N Rows[foundRows] = dtSmall:N Rows[i]
);
);
回复:無需輔助列就可以直接獲取匹配數據嗎?謝謝吉姆!
代碼沒有運行。

回复:無需輔助列就可以直接獲取匹配數據嗎?好吧,JMP找不到小的數據表。從您的主要提交中可以看到,小型數據表的數據表名稱稱為“按年齡,性別劃分的大類”。不是正確的名稱,或者該數據表不再存在。只需將數據表引用的名稱更改為要在其上運行腳本的表並運行它。回复:無需輔助列就可以直接獲取匹配數據嗎?我已經對其進行了多次修改,但仍然沒有解決方案。
繼續尋求您的幫助。謝謝吉姆!回复:無需輔助列就可以直接獲取匹配數據嗎?試試這個
names default to here(1);
// Create the 2 Example data tables
dtBig = open("$SAMPLE_DATA/big class.jmp");
dtSmall = New Table( "Data agesex",
Add Rows( 12 ),
New Column( "agesex",
Character,
"Nominal",
Set Values(
{"12F", "12M", "13F", "13M", "14F", "14M", "15F", "15M", "16F", "16M",
"17F", "17M"}
)
),
New Column( "N Rows",
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 0 ),
Set Values( [5, 3, 3, 4, 5, 7, 2, 5, 2, 1, 1, 2] )
)
);
// Create the new column
dtBig << New Column( "N Rows" );
// Move the data as required
For( i = 1, i <= N Rows( dtSmall ), i++,
foundRows = dtBig << get rows where(
Num( Substr( dtSmall:agesex[i], 1, Length( dtSmall:agesex[i] ) - 1 ) ) == :age &
Substr( dtSmall:agesex[i], -1 ) == :sex
);
If( N Rows( foundRows ) > 0,
dtBig:N Rows[foundRows] = dtSmall:N Rows[i]
);
);回复:無需輔助列就可以直接獲取匹配數據嗎?謝謝吉姆!
dtSmall
dtBig = Open( "$SAMPLE_DATA/big class.jmp" );
dtSmall = dtBig << Summary(
Group( :age, :sex ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 ),
statistics column name format( "column" )
);
c1 = Column( 1 ) << Get Name;
c2 = Column( 2 ) << Get Name;
dtSmall << Add Multiple Columns( c1 || c2, 1, after( As Column( 2 ) ), Character, "Nominal" );
Wait( 0 );
Column( 3 ) << Formula( Char( :age ) || :sex );
dtSmall << run formulas;
Column( 3 ) << deleteFormula;
dtSmall << delete columns( 1 :: 2 );
可以在沒有輔助列的情況下直接獲取匹配數據嗎?例如,使用“ Big class.jMP”的“ age”列和“ sex”列組合在另一個表上生成新的列名。
如何直接通過“年齡”和“性別”列匹配另一張表的數據,而不在大表中添加輔助列?
謝謝!
腳本編寫