cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
dn610
Level III

How to Tell JMP to continue running the Script when Column is Missing

Hi - when creating a summary table below, does anyone know how to code in JSL to allow the script to continue running  if any one of the columns below do not exist? 

 

dt3 << Summary(Sum( :Fail, :Not Assessed, :Weak));

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to Tell JMP to continue running the Script when Column is Missing

I find the easiest way to do this, is to create a list of the columns available, and then reference that list in the Summary platform.

Names Default To Here( 1 );
dt3 = Current Data Table();
colList = dt3 << get column names( continuous, string );
dt3 << summary( Sum( Eval( colList ) ) );

There are multiple ways to populate the list, and to delete items from the list.  See the documentation on manipulating lists in the Scripting Guide

Jim

View solution in original post

3 REPLIES 3
ErraticAttack
Level VI

Re: How to Tell JMP to continue running the Script when Column is Missing

You need to do a little bit of code safing on the list of columns to summarize.

 

Here is my example:

 

dt3 = Current Data Table();
columns to summarize = {"fail", "not assessed", "weak"};	//columns you're interestd in, may or may not exist within table
column names = dt3 << Get Column Names( "String" );		//we need to grab the table columns to utilize only available columns
columns as names = {};						//we need to wrap both column names and our columns of interest in 
For( i = 1, i <= N Items( column names ), i++,			//  'As Name( ... )' to avoid issues with capitalization and such
	columns as names[i] = As Name( column names[i] )	//  loop here
);

columns to summarize within table = {};
For( i = 1, i <= N Items( columns to summarize ), i++,
	If( Contains( columns as names, As Name( columns to summarize[i] ) ),	// check to see that name exists as column header
		Insert Into( columns to summarize within table, columns to summarize[i] )
	)
);
Eval( Eval Expr(
	dt3 << Summary( Expr( Substitute( columns to summarize within table, {}, Expr( Sum ) ) ) ) //fancy substitution for the summary table
) )
Jordan
txnelson
Super User

Re: How to Tell JMP to continue running the Script when Column is Missing

I find the easiest way to do this, is to create a list of the columns available, and then reference that list in the Summary platform.

Names Default To Here( 1 );
dt3 = Current Data Table();
colList = dt3 << get column names( continuous, string );
dt3 << summary( Sum( Eval( colList ) ) );

There are multiple ways to populate the list, and to delete items from the list.  See the documentation on manipulating lists in the Scripting Guide

Jim
dn610
Level III

Re: How to Tell JMP to continue running the Script when Column is Missing

This worked. Thank you!