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
Hari
Level III

A very simple script is not working due to large no of rows, any suggestion ?

Hello,

 

I have a large set of data and I want to add a new column (Character) based on a pattern in another column. I have tested the script on small table, it is working fine but on my actual data set, it keep on trough error, see the attached image. No of rows in my data table is -- 1.8x10^6 and I am sure that is the issue. Is there any way I can make the evaluation bit slow in the script, hopefully that will work. Or any other idea/ suggestion.

 

Any help.

Error-2.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: A very simple script is not working due to large no of rows, any suggestion ?

  1. Check the spelling of the column name in the large table.
  2. I've never used the EvalFormula, and the if statement has an unusual trailing comma. Try something like this
dt = Open( "$sample_data/big class.jmp" );

dt << New Column( "Cat", Character, "Nominal",
	Formula(
		If(
			Contains( :sex, "M" ), "male",
			Contains( :sex, "1" ), "one",
			Contains( :sex, "2" ), "two",
			Contains( :sex, "3" ), "three",
			"female" // the otherwise case
		)
	)
);
	
dt << runformulas;
Craige

View solution in original post

4 REPLIES 4
Highlighted
txnelson
Super User

Re: A very simple script is not working due to large no of rows, any suggestion ?

I replicated your data into a data table with 2.7 million rows, and did not get a failure.  Are the values of :Parameter more complex in your real data?  Does the key that you are looking for always fall as the second segment of the Parameter

     xx_KEY_xxx_xxx

Jim
Highlighted
Hari
Level III

Re: A very simple script is not working due to large no of rows, any suggestion ?

Hi Nelson,

 

Thanks for prompt reply. No they are not complex and yes, I am always looking for the 2nd segment of parameter as you described. Is there any other way to make it happen ?

Highlighted
Craige_Hales
Staff (Retired)

Re: A very simple script is not working due to large no of rows, any suggestion ?

  1. Check the spelling of the column name in the large table.
  2. I've never used the EvalFormula, and the if statement has an unusual trailing comma. Try something like this
dt = Open( "$sample_data/big class.jmp" );

dt << New Column( "Cat", Character, "Nominal",
	Formula(
		If(
			Contains( :sex, "M" ), "male",
			Contains( :sex, "1" ), "one",
			Contains( :sex, "2" ), "two",
			Contains( :sex, "3" ), "three",
			"female" // the otherwise case
		)
	)
);
	
dt << runformulas;
Craige

View solution in original post

Highlighted
Hari
Level III

Re: A very simple script is not working due to large no of rows, any suggestion ?

Yes, it is working find. thanks.

Article Labels