こんにちは。行ごとに複数の製品のデータを含む列セットがあります。製品名の接尾辞を持つ新しい同一の列を作成し、前の列から一致する製品データのみをコピーして、このデータを分割する必要があります。適切なデータをコピーする方法を教えてください。選択とコピー貼り付けでこれを実行しようとしましたが、方法がわかりません。関心領域は、dt << Select Where 以降から始まります。
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << Get Column Names(String);
//Select set of columns to split
for (i = nitems(colNames), i > 0, i--,
if (!contains(colNames[i], "SPC"),
remove from(colNames, i);
);
);
//Add new columns with product name suffix and copy/paste properties
Summarize(unique_values=by(:Products));
colNames2=colNames;
for (k = nitems(unique_values), k > 0, k--,
for (i = nitems(colNames), i > 0, i--,
colNames2[i] = colNames[i] || " " || unique_values[k];
dt << New Column( colNames2[i] );
);
for( j = 1, j <= nitems(colNames), j++,
colProps = Column( dt, colNames[j] ) << Get Column Properties;
Column( dt, colNames2[j] ) << Add Column Properties( colProps );
);
<U><STRONG> dt << Select Where( :Products == unique_values[k] );
dt << selectColumns(colNames);
dt << Copy;
dt << selectColumns(colNames2);
dt << Paste;</STRONG></U>
);
行の選択に基づいて値をコピーして貼り付けたい場合は、次のようなコードを記述できます。
お役に立てば幸いです。
dt << Select Where( :Products == unique_values[k] );
r = dt << Get Selected Rows();
val = As Column( colNames[i] )[r];
For( h = 1, h <= N Row( val ), h++,
As Column( colNames2[i] )[r[h]] = val[h]
);