Hi, Below (section A) is my code for a formula in a new column and it is working. However, I want to use for loop to replace it. I tried on it(Section B) , but there is not output at all. I wonder if someone can give me some advice of my mistake on section B? the example of column smap1 is in attached table. Thanks
section A:
dt3 << new column("smap", character,
formula(
If(N Rows( Loc( Words( :smap1, "," ), "0" ) ) >= 3, "0:0:0:0:0:0:0:0",
N Rows( Loc( Words( :smap1, "," ), "1" ) ) >= 3, "1:1:1:1:1:1:1:1",
N Rows( Loc( Words( :smap1, "," ), "2" ) ) >= 3, "2:2:2:2:2:2:2:2",
N Rows( Loc( Words( :smap1, "," ), "3" ) ) >= 3, "3:3:3:3:3:3:3:3",
N Rows( Loc( Words( :smap1, "," ), "4" ) ) >= 3, "4:4:4:4:4:4:4:4",
N Rows( Loc( Words( :smap1, "," ), "5" ) ) >= 3, "5:5:5:5:5:5:5:5",
N Rows( Loc( Words( :smap1, "," ), "6" ) ) >= 3, "6:6:6:6:6:6:6:6",
N Rows( Loc( Words( :smap1, "," ), "7" ) ) >= 3, "7:7:7:7:7:7:7:7",
"0:1:2:3:4:5:6:7"
);
);
);
section B:
dt3 << new column("smap", character,
formula(
map={"0","1","2","3","4","5","6","7"};
for (l=1, l<=N items(map), l++,
A=":"||map[l];
B=map[l];
If(N Rows( Loc( Words( :smap1, "," ), char(map[l])) )>= 3, concat(B,A,A,A,A,A,A,A),
"0:1:2:3:4:5:6:7"
);
)
)
);