BookmarkSubscribeSubscribe to RSS Feed
daniel_harding

Community Trekker

Joined:

Jul 2, 2012

Deleting two rows and repeating the rest of the data

Hi,

I have a new column in my data table and using JSL,  I need to remove the first two rows of the column, move the remaining data up to the top of the column, and then repeat those values until the final row.  Attached with this question is what it looks like right now.

Thanks for any suggestions or help!

1 ACCEPTED SOLUTION

Accepted Solutions
wiebepo

Community Trekker

Joined:

Oct 10, 2011

Solution

Re: Deleting two rows and repeating the rest of the data

This should work for the example. Replace 'Column 1' with the column name of interest.

data_raw=currentdatatable();

data_table=data_raw<<subset(rows(

          data_raw<<getrowswhere(

               !ismissing(:Column 1)

               &row()!=1

               &row()!=2

          );

     ),

     invisible

);

data_rows=column(data_table,"Column 1")<<getasmatrix();

close(data_table,nosave);

For(i=1;k=1,i<=nrows(data_raw),i++;k++,

     column(data_raw,"Column 1")=data_rows;

     If(k==nrows(data_rows),k=0);

);

2 REPLIES
wiebepo

Community Trekker

Joined:

Oct 10, 2011

Solution

Re: Deleting two rows and repeating the rest of the data

This should work for the example. Replace 'Column 1' with the column name of interest.

data_raw=currentdatatable();

data_table=data_raw<<subset(rows(

          data_raw<<getrowswhere(

               !ismissing(:Column 1)

               &row()!=1

               &row()!=2

          );

     ),

     invisible

);

data_rows=column(data_table,"Column 1")<<getasmatrix();

close(data_table,nosave);

For(i=1;k=1,i<=nrows(data_raw),i++;k++,

     column(data_raw,"Column 1")=data_rows;

     If(k==nrows(data_rows),k=0);

);

daniel_harding

Community Trekker

Joined:

Jul 2, 2012

Re: Deleting two rows and repeating the rest of the data

That works perfectly. Thank you so much!