ループで一連の列を再コーディングするこんにちは、
私はしばしばマルチパンチデータを別々の列に「展開」して受け取っていますが、そこではオプション1 = 1、オプション2 = 2などに対する肯定的な回答があります。これらをバイナリに書き直す必要があります。これを再現可能なスクリプトで作成したいと思います。次のスクリプトを順調に進んでいると思いますが、実行するとエラー「アクセスまたは 'Subscriptの評価でオブジェクトが添え字できません{1}」が表示されます。サンプルデータセットを添付しました。前もって感謝します。
dt = Current Data Table();
lstColNames = {"14_1","14_2","14_3","14_4","14_5","14_6","14_7","14_8","14_9","14_10","14_11","14_12","14_13"};
For Each Row( For( i = 1, i <= N Items( lstColNames ), i++, If( lstColNames[i][]== i, lstColNames[i][] = 1 ) ) );
再:ループで一連の列を再コード化するありがとうございます。私はこれを使って自分のプロジェクト用の再現可能なスクリプトを作成することができました。アシスタントに感謝します。
再:ループで一連の列を再コード化するFor( i = 1, i <= 13, i++,
For()ループを減らすだけ
再:ループで一連の列を再コード化するTXさん、ありがとうございます。もっと多くの列を含むより大きなデータセットにある場合、どうすればこれを列14_1から14_13だけに制限できますか?それが私が特定のリストを使おうとしていた理由です。
再:ループで一連の列を再コード化するこれがあなたが望むものであるかどうか見てください
Names Default To Here( 1 );
dt = Current Data Table();
lstColNames = dt << get column names( string, nominal );
For( i = 1, i <= N Items( lstColNames ), i++,
theRows = dt << get rows where( As Column( dt, lstColNames[i] ) >= 1 );
If( N Rows( theRows ) > 0,
Column( dt, lstColNames[i] )[theRows] = 1
);
theRows = dt << get rows where( Is Missing( As Column( dt, lstColNames[i] ) ) == 1 );
If( N Rows( theRows ) > 0,
Column( dt, lstColNames[i] )[theRows] = 0
);
Column( dt, lstColNames[i] ) << delete property( "Value Labels" );