split rows

Hi I wanted to split rows based on the number of 1's present in 21st field(21st field is 40 length field) so I wrote the below awk code. However, the tool that I am using to invoke the command is not recognising the command. So, could you please help me to translate this command to sed?

awk '{for ( i=1; i<=40; i++) {  if ( substr($21,i,1) == 1) print $1 $2 i $5 $7  }}'

what error you are getting??

I am not sure which tool are you using to invoke the command? Can it recognize and translate any other unix commands?

I am not getting any error. the scenario is like this. I am trying to invoke the command from the datastage external filter stage. when I run the command

awk '{  for (i=1; i<=40; i++) {  print $0 }}'

through datastage It works fine. However, When I add the if condition and multiple fields to be printed it doesnt work. So I thought it would be helpful if I can try it in sed.

if simple awk works and after ading if it doesn't work means it might not be satisfying the condition you gave

Well, the same command works fine from unix prompt but it doesnt work from the DS