今回はINDEXC関数について解説します。
data data1;
Id1="1111"; Id2="1111"; Id3="1111";
output;
Id1="2111"; Id2="2111"; Id3="2111";
output;
Id1="2211"; Id2="2211"; Id3="2211";
output;
Id1="2221"; Id2="2221"; Id3="2221";
output;
Id1="2222"; Id2="2222"; Id3="2222";
output;
Id1="3333"; Id2="3333"; Id3="3333";
output;
run;
data data2; set data1;
Id4 = indexc(Id1, "1" );
run;


- INDEXCにより、第二引数を1文字ずつ分解し、文字が第一引数の何文字目に見つかったかを返す。
- 見つからない場合は0。
/* indexc 12 */
data data1;
Id1="1111"; Id2="1111"; Id3="1111";
output;
Id1="2111"; Id2="2111"; Id3="2111";
output;
Id1="2211"; Id2="2211"; Id3="2211";
output;
Id1="2221"; Id2="2221"; Id3="2221";
output;
Id1="2222"; Id2="2222"; Id3="2222";
output;
Id1="3333"; Id2="3333"; Id3="3333";
output;
run;
data data2; set data1;
Id4 = indexc(Id1, "12" );
run;


- INDEXCにより、第二引数を1文字ずつ分解し、文字が第一引数の何文字目に見つかったかを返す。(1または2を探す)
- 見つからない場合は0。