cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ENTHU
Level IV

Issue with word and substring

I am working on a data table with more than 4000 rows.To get the data in required format I'm using word and substr functions within for each row loop. The functions work as expected for first 160 rows and no action is taken on rows beyond this point.Is this a network issue ? I tried adding Wait but doesnt help.

 

For Each Row(dt:col1 = Word(1,dt:col1, "S"));

For Each Row(dt:col2 = Substr( Char(dt:col2 ), 3, 2 ));

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Issue with word and substring

@ENTHU,

 

A couple items, you are looping thru 4000 rows twice. You might want to loop once. You can use For Each Row( stmt1; stmt2 ) or a for loop. Also your code has dt:col2 = Substr( Char(dt:col2), 3, 2). Why do you have the Char() function? Does col2 have Character data type?   

 

Below is an example using a For Loop, assuming col2 is defined as Character data type.  You should look at the values in row 161 

 

For(i=1, i<=nrow(dt), i++,
  dt:col1[i] = word(1, dt:col[1], "S");
  dt:col2[i] = Substr( dt:col2[i], 3,2 );	
);

View solution in original post

3 REPLIES 3
gzmorgan0
Super User (Alumni)

Re: Issue with word and substring

@ENTHU,

 

A couple items, you are looping thru 4000 rows twice. You might want to loop once. You can use For Each Row( stmt1; stmt2 ) or a for loop. Also your code has dt:col2 = Substr( Char(dt:col2), 3, 2). Why do you have the Char() function? Does col2 have Character data type?   

 

Below is an example using a For Loop, assuming col2 is defined as Character data type.  You should look at the values in row 161 

 

For(i=1, i<=nrow(dt), i++,
  dt:col1[i] = word(1, dt:col[1], "S");
  dt:col2[i] = Substr( dt:col2[i], 3,2 );	
);
ENTHU
Level IV

Re: Issue with word and substring

I got rid of for each row and used for loop to make it work.

 

Thanks

Re: Issue with word and substring

Can you show us a couple of rows before row 160 and a couple after row 160?