Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Nino
Level I

Using tabulate to reorder all data table values

Hello,

 

This is probably an easy question, however so far I just was not able to solve it in JMP 12.

 

I have a data table that I need to reorder. The data table has basically the following outline

BatchTimepointObservation
102
102
102
114
114
114
20...

To process the data table in another programm I need the following outline

TimepointObservation Batch 1Observation Batch 2
02 
02 
02 
14 
14 
14 

While it is pretty straight foward to tabulate the mean values for example by using Analyze-> Tabulate, I just can not find a way to have every observation in the new data table.

Any hints how to do that?

 

Thank you in advance for your help.

 

Nino

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: Using tabulate to reorder all data table values

Take a look at the menu option 'Tables > Split' and the associated Help.

 

In JSL:

NamesDefaultToHere(1);

dt1 = New Table( "Stacked",
				Add Rows( 12 ),
				New Column( "Batch",
					Numeric,
					"Nominal",
					Format( "Best", 12 ),
					Set Values( [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] )
				),
				New Column( "Timepoint",
					Numeric,
					"Ordinal",
					Format( "Best", 12 ),
					Set Values( [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1] )
				),
				New Column( "Observation",
					Numeric,
					"Continuous",
					Format( "Best", 12 ),
					Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] )
				)
			);

// 'Tables > Split'
dt2 = dt1 << Split(
			Split By( :Batch ),
			Split( :Observation ),
			Output Table( "Split" )
			);

Copy and paste the code above into a new script window ('File > New > New Script'), then do 'Edit > Run Script'.

View solution in original post

2 REPLIES 2
Highlighted
ian_jmp
Staff

Re: Using tabulate to reorder all data table values

Take a look at the menu option 'Tables > Split' and the associated Help.

 

In JSL:

NamesDefaultToHere(1);

dt1 = New Table( "Stacked",
				Add Rows( 12 ),
				New Column( "Batch",
					Numeric,
					"Nominal",
					Format( "Best", 12 ),
					Set Values( [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] )
				),
				New Column( "Timepoint",
					Numeric,
					"Ordinal",
					Format( "Best", 12 ),
					Set Values( [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1] )
				),
				New Column( "Observation",
					Numeric,
					"Continuous",
					Format( "Best", 12 ),
					Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] )
				)
			);

// 'Tables > Split'
dt2 = dt1 << Split(
			Split By( :Batch ),
			Split( :Observation ),
			Output Table( "Split" )
			);

Copy and paste the code above into a new script window ('File > New > New Script'), then do 'Edit > Run Script'.

View solution in original post

Highlighted
Nino
Level I

Re: Using tabulate to reorder all data table values

Thank you!

This works perfect. 

 

What confused me was the fact, that I had to keep the "Timepoint" column by choosing an option for the remaining columns in the split dialog (as my data table has some additional columns it does "look" correctly if I keep all the columns).

I had some trouble getting the split command to work with regards to the option for remaining columns in jsl. It would be nice if there was an additional comment in the scripting index on how to get remaining columns to work (since you obviously have to add "keep" or "drop" is you want to select certain columns).

(Even though of course it is easier to just copy the script from the "source" part of the newly created data table).

 

Have a nice day!

 

Nino

 

Article Labels

    There are no labels assigned to this post.