Deleting a row renumbers all subsequent rows so it's better to start from the bottom and search up. This variation also uses the mark command to delete the row...
work -d maindata; get maindata_C -e rownum; // number of rows for(i2=rownum; i2>0; i2--) { if(maindata_C[i2]==2) mark -d maindata_C -b i2 -e i2; };
However, the following method will be much faster because it does not have to examine every row. It uses the list() function to find the next occurrence of the specified value.
work -d maindata; for(i2=1;i2>0;i2++) { ii=list(2,maindata_C); if(ii==0) break; mark -d maindata_C -b ii -e ii; };