cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
zetaVagabond1
Level II

how to Resolution Problem with Formula for Column

Code: 

If(

!Contains(col_name_list, "EFT (h)"),

Current Data Table() << New Column(

"EFT (h)",

Numeric,

Continuous,

Format("Fixed Dec", 10, 1),

Formula(

:Name( "duration" ) * 24

)

)

);



Error:

Unexpected ")". Perhaps there is a missing ";" or ",".

Line 9 Column 6:    ))►)

 

The remaining text that was ignored was

)

Resolution Problem with Formula for Column EFT (h):

 

I am unable to figure out, what this could be. 

 

I have tried this too: 

If(
	!Contains(col_name_list, "EFT (h)"),
	Current Data Table() << New Column(
		"EFT (h)",
		Numeric,
		Continuous,
		Format("Fixed Dec", 10, 1),
		Formula(:duration * 24)
	)
);
7 REPLIES 7
zetaVagabond1
Level II

Re: how to Resolution Problem with Formula for Column

If(
	!Contains(col_name_list, "EFT (h)"),
	Current Data Table() << New Column(
		"EFT (h)",
		Numeric,
		Continuous,
		Format("Fixed Dec", 10, 1),
		Formula( 
		:Name( "EFT (h)" ) * 24 
		)
	)
);

using this

hogi
Level XII

Re: how to Resolution Problem with Formula for Column

Please note that in the last version the column duration is replaced with column EFT(h).
To find issues with commas, you can double click on a bracket and the corresponding bracket will be marked as well - together with the enclosed script.

Another option: use reformat script.
It works like executing the code: the syntax is checked and in case of an error the line of with the error will be indicated in the log.

hogi_0-1757672127191.png

 

Applying such checks, there are no issues with commas in your code.

Besides manual checks, some automation will help. e.g. automatic coloring of the code, like suggested in this wish:
Advanced syntax highlighting in JSL Editor - does the function evaluate its argument? 

hogi
Level XII

Re: how to Resolution Problem with Formula for Column

The most complicate issue with unbalanced brackets:

for ( i=1, i < 10, i++, 
	list = { A, B, C ;
	E+F;
);

hogi_0-1757674207545.png

 

... the issues with "balanced" brackets.
When you position the cursor behind the closing bracket, it shows the corresponding opening bracket:

hogi_1-1757674420131.png

So, everything OK? Why the error message abut the closing ")"?

 

JMP has a hint:

hogi_2-1757674445786.png

So, let's check the curly brackets ...

 

 

Interesting, in your case the suggestion was:

hogi_3-1757674546211.png
?

zetaVagabond1
Level II

Re: how to Resolution Problem with Formula for Column

Thanks, I shall check this link. I do not know these yet.

jthi
Super User

Re: how to Resolution Problem with Formula for Column

Both of these scripts do work fine for me

Names Default To Here(1);

col_name_list = {};

dt = New Table("table",
	New Column("duration", Numeric, Continuous, Values([1]))
);


If(!Contains(col_name_list, "EFT (h)"),
	Current Data Table() << New Column("EFT (h)",
		Numeric,
		Continuous,
		Format("Fixed Dec", 10, 1),
		Formula(:Name("duration") * 24)
	)
);

Generally reformatting scripts should be able to capture most of the issues.

 

Also I would suggest not using Name() for cases like this (within formulas), unless you are on some much older version of JMP, as it has been replaced with ""n

Scripting Guide > JSL Building Blocks > JSL Syntax Rules > JSL Rules for Names 

jthi_0-1757744574424.png

 

-Jarmo
zetaVagabond1
Level II

Re: how to Resolution Problem with Formula for Column

Thanks, I check for the formatting, it seems fine. I am unable to locate this error. 

Unexpected ")". Perhaps there is a missing ";" or ",".

To give some context, the script I am working on is a legacy script written in previous JMP version 14/15 maybe. This works for the purpose it's designed. Now, I am re-purposing it. 

I wasn't aware of using Name(), you suggest I should just use column-name directly, perhaps like

Names Default To Here(1);

col_name_list = {};

dt = New Table("table",
	New Column("duration", Numeric, Continuous, Values([1]))
);


If(!Contains(col_name_list, "EFT (h)"),
	Current Data Table() << New Column("EFT (h)",
		Numeric,
		Continuous,
		Format("Fixed Dec", 10, 1),
		Formula(:duration * 24)
	)
);

or duration * 24. 

 

Very new to this. Would it be easier to repurpose this whole bunch of code in python? Would then I still have to define all the column parameters like - type, formats, modeling type? Thanks

 

jthi
Super User

Re: how to Resolution Problem with Formula for Column

Without seeing the script it is difficult to say what could be the problem, as the scripts you have provided to work just fine. 

 

Is there specific reason to rewrite it in Python? If it is going to be still used within JMP, I would not use Python (most of the time) to do tasks which could be also done with JSL.

-Jarmo

Recommended Articles