cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
StarfruitBob
Level VI

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

  1. Save the value <= 1 in Col A
  2. Create new column, Col A_2
  3. Insert saved data from step 1
  4. 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.

Screenshot 2022-05-18 153217.png

 

I truly value your help!

Learning every day!
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

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] = .;
	);
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

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] = .;
	);
);
Jim
StarfruitBob
Level VI

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!

Learning every day!
txnelson
Super User

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.

 

Jim
StarfruitBob
Level VI

Re: Blocks of data - reorganization

Thank you!

Learning every day!