- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Blocks of data - reorganization
Hello! I have "blocks" of data, where multiple rows correspond to one data point. Within this block, I have a column where some values are stacked. I wish for these values to be in a single row.
By scripting, how do I
- Save the value <= 1 in Col A
- Create new column, Col A_2
- Insert saved data from step 1
- Repeat with all blocks. Blocks are illustrated below by: Row A,B; Row C,D; Row E,F
The distance between the value > 1 and <=1 can vary anywhere from right next to each other to a lot of data, but the data always seems to be value > 1, n amount of rows, value <= 1.
I truly value your help!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Blocks of data - reorganization
Here is a simple script that works on your sample data. It should give you a good start on a way to approach your big table
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Col A_2" );
dt << go to( :Col A_2 );
dt << move Selected Columns( After( :Col A ) );
For( i = 1, i <= N Rows( dt ), i++,
If( :Col A[i] > 1,
holdRow = i
);
If( :Col A[i] <= 1,
:Col A_2[holdRow] = :Col A[i];
:Col A[i] = .;
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Blocks of data - reorganization
Here is a simple script that works on your sample data. It should give you a good start on a way to approach your big table
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Col A_2" );
dt << go to( :Col A_2 );
dt << move Selected Columns( After( :Col A ) );
For( i = 1, i <= N Rows( dt ), i++,
If( :Col A[i] > 1,
holdRow = i
);
If( :Col A[i] <= 1,
:Col A_2[holdRow] = :Col A[i];
:Col A[i] = .;
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Blocks of data - reorganization
Thank you so much, txnelson! This works!
Question, what does holdRow do? I've searched the scripting guide for v14 & 16 and didn't find it.
I've also figured out how to delete the row that data was coped from and all of the rows in between the >1 value and <= 1 value, so this data looks much better!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Blocks of data - reorganization
holdRow is just the name I gave to a JMP scaler variable that holds the last row where the value of Col A was greater than 1. The name holdRow could be any name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Blocks of data - reorganization
Thank you!