異なるサイズの2つのデータテーブルを反復し、一致する値を比較するこんにちは、
次のような問題があります。
- 別々のjmpファイルに2つのデータテーブルがあり、それぞれに1つの列があります。
- 1つのテーブルの長さは8行、もう1つのテーブルの長さは6440行です。
- 私の目的は、8行のテーブル内の各値を調べて、それらを6440行のテーブル内のすべての値と比較して、一致するかどうかを確認することです。
- 両方のテーブルを反復処理したいのですが、サイズが異なるため、これを実行する方法を考えていました。入れ子になったforループを使うことを考えていましたが、あまりわかりません。
任意の助けがいただければ幸いです。
異なるサイズの2つのデータテーブルを反復処理し、一致する値を比較する前の疑似コードの例で少しエラーを犯しました、
dtShort:Compare Column[i] > dtLong:Compare Column</CODE></PRE>
<P><SPAN>それが機能するためには論理を逆にする必要がある</SPAN></P>
<PRE><CODE class=" language-jsl"> dtLong:Compare Column > dtShort:Compare Column[i]
これは実用的な例です
Names Default To Here( 1 );
dtLong = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create the short data table
dtShort = New Table( "Short",
New Column( "Target Age", values( {12, 16} ) ),
New Column( "Match", character, values( {"Teenager", "Young Adult"} ) )
);
// Sort the data for illustration of data not being
// in age order
dtLong << sort( by( :Name ), replace table( 1 ) );
// Create a couple of new columns in the data table
dtLong << New Column( "Kind Of Match", character );
dtLong << New Column( "Count" );
// Process the data
For( i = 1, i <= N Rows( dtShort ), i++,
// Find all rows that match the Where Clause
theRowsFound = dtLong << get rows where( dtLong:Age > dtShort:Target Age[i] );
// If some rows were found process
If( N Rows( theRowsFound ) > 0,
// Set a value in the dtLong data table with one statement
// that sets values in multiple rows
dtLong:Kind Of Match[theRowsFound] = dtShort:Match[i];
// Now set values row by row for individual rows that were found
theCount = 1;
For( k = 1, k <= N Items( theRowsFound ), K++,
dtLong:Count[theRowsFound[k]] = theCount;
theCount = theCount + 1;
);
);
);異なるサイズの2つのデータテーブルを反復処理し、一致する値を比較する早速のお返事ありがとうございます。
次の部分について
dtLong : Compare Column
列の各添え字/インデックスを参照しなくても、列のすべての値にアクセスできる方法を説明してもよろしいですか。
異なるサイズの2つのデータテーブルを反復処理し、一致する値を比較するこれが私がそれを処理する方法です.......
// This is pseudo code, but it will give you an idea of the flow
dtShort = Open( "<YOUR short="" data="https://community.jmp.com/" table="">" );
dtLong = Open( "<YOUR long="" data="https://community.jmp.com/" table="">" );
For( i = 1, i <= N Rows( dtShort ), i++,
theRowsFound = dtLong << get rows where( dtShort:Compare Column[i] > dtLong:Compare Column );
If( N Rows( theRowsFound ) > 0,
// Do your processing
);
);</YOUR></YOUR>
異なるサイズの2つのデータテーブルを反復処理し、一致する値を比較するお返事をありがとうございます。
8行のテーブルの値が大きい 6440行のテーブルの値よりも?
異なるサイズの2つのデータテーブルを反復処理し、一致する値を比較するこれを行う最も簡単な方法は、JMPに仕事を任せてもらうことだと思います。 テーブルを新しいテーブルに結合する場合は、JMPにMatch flagという名前で新しい列を作成させることができます。これにより、一致が見つかったかどうかがわかります。
テーブル==>結合