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
Lien
Level II

Need help with scripts for columns

Hey!

 

I am trying to automate the creation of some columns, which are always needed but the data that It'd take differs from table to table.

The format of each table would stay the same but the amount of data could differ so this script should work no matter the amount.

 

1. I need to select all data of the column "Igtr_6V" where the TEMP is 25.

2. I need to copy said data, create a new column, paste it in there and fill the data to the end of table.

3. Create a new column where I need the Median of the previously selected values. This would result in 1 value and should be filled to the end of table aswell.

4. Create one last column which divides every "Igtr_6V" value with the value on the same row in the column that we created in step 2 using a formula.

 

As I said, this process should be automated via script and universally applicable as long as the format of the table stays the same.

 

I will attach pictures of examples and the data table.

 

Every bit of help is appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Need help with scripts for columns

The purpose of the Community, is to solve issues that members are having with JMP, not as an organization who is there to writ scripts-on-demand.  Those requests have contract houses available for hire. 

The proper beginning to solve your question is to read the JSL Scripting Guide in the JMP Documentation Library, available under the Help pull down menu.

I have put together a script that I believe gets you where you want to go.  But you need to study it, so you understand what it does,  You will need the knowledge from the Scripting Guide to aid you in the interpretation.

Names Default To Here( 1 );
dt = Current Data Table();

// 1. I need to select all data of the column "Igtr_6V" where the TEMP is 25.
val25 = :Igtr_6V[dt << get rows where( :temp == 25 )];

// 2. I need to copy said data, create a new column, paste it in there and fill the data to the end of table.
dt << New Column( "IGT@25C",
	set each value(
		themod = Mod( Row(), Length( val25 ) );
		If( themod == 0,
			themod = Length( val25 )
		);
		val25[themod];
	)
);

// 3. Create a new column where I need the Median of the previously selected values
//    This would result in 1 value and should be filled to the end of table aswell.
dt << New Column( "IGT@25C median", set each value( Median( val25 ) ) );

// 4. Create one last column which divides every "Igtr_6V" value with the value on
//    the same row in the column that we created in step 2 using a formula
dt << New Column( "IGT(T)/IGT(25)", formula( :Igtr_6V / :"IGT@25C"n ) );
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Need help with scripts for columns

The purpose of the Community, is to solve issues that members are having with JMP, not as an organization who is there to writ scripts-on-demand.  Those requests have contract houses available for hire. 

The proper beginning to solve your question is to read the JSL Scripting Guide in the JMP Documentation Library, available under the Help pull down menu.

I have put together a script that I believe gets you where you want to go.  But you need to study it, so you understand what it does,  You will need the knowledge from the Scripting Guide to aid you in the interpretation.

Names Default To Here( 1 );
dt = Current Data Table();

// 1. I need to select all data of the column "Igtr_6V" where the TEMP is 25.
val25 = :Igtr_6V[dt << get rows where( :temp == 25 )];

// 2. I need to copy said data, create a new column, paste it in there and fill the data to the end of table.
dt << New Column( "IGT@25C",
	set each value(
		themod = Mod( Row(), Length( val25 ) );
		If( themod == 0,
			themod = Length( val25 )
		);
		val25[themod];
	)
);

// 3. Create a new column where I need the Median of the previously selected values
//    This would result in 1 value and should be filled to the end of table aswell.
dt << New Column( "IGT@25C median", set each value( Median( val25 ) ) );

// 4. Create one last column which divides every "Igtr_6V" value with the value on
//    the same row in the column that we created in step 2 using a formula
dt << New Column( "IGT(T)/IGT(25)", formula( :Igtr_6V / :"IGT@25C"n ) );
Jim
Lien
Level II

Re: Need help with scripts for columns

Hello!

 

I apologise for my frequent questions.

I am currently working as an intern at this company so I do not have the time to study the ins and outs of JMP.

Sadly nobody here really knows anything about scripting in JMP as I am probably the first one to concern myself with it since they just recently switched from Excel.

These are my last few days here and I would like to complete the task given to me before leaving. Over the last few weeks I have learned a lot about JMP and JSL and that is partly thanks to this community.

 

So I genuinely appreciate your and everyone else's help! 

Again, sorry if I sound rude or unthankful! This will probably be my last post here anyways before I go back to school