cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
TheDude
Level III

Warning: Avoid using dashes in column names!

This is mostly unexpected and it took me a while to figure out. 

If you use dashes ('-') in column names, bad things can happen. 

 

Consider the following case: you want to calculate the mean of two columns. So you open the Formula Editor and pick Statistics>Mean, then try to drag the columns inside the parentheses. In JMP16, this used to work just fine. In JMP17, things have changed a bit, I think. 

 

Now try this with the column names Col-1 and Col-2 or Col_1 and Col_2. With the underscore, you can use commas between the column and the formula will look like this:

Screenshot 2023-04-24 171839.png

Now try the same for the columns with dashes in their names. First, a parsing error appears. You can then try to put the column names within double quotes. It's hard to do, but if you do the right incantation, you will end up with a formula that looks like this:

Screenshot 2023-04-24 172721.png

At this point, the mean is calculated correctly. 

 

However, it is NOT the same. This breaks, for example, if you try to use Profiled to calculate a function based on Predicted formulas. Even though you check the "Expand Intermediate Formulas", it will fail with an error about missing factors. It will work if no dashes in the column name!

 

I think this is clearly a bug, and a nasty one. 

3 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Warning: Avoid using dashes in column names!

JMP took the route in it's syntax, to have as few "special" or "restricted" characters in naming variables or columns, etc.  The end re result is that it is possible that JMP will interpret an variable  or column name as a mathematical phrase, rather than a qualified name.  Thus, 

Col-1

would be evaluated as a variable named "Col" minus 1.

JMP has syntax that allows for the correct interpretation.

:"Col-1"n

tells JMP this is a column name and the column name is "Col-1".

Your Mean() function example is coded as

Mean( :"Col-1"n,  :"Col-2"n );
Jim

View solution in original post

jthi
Super User

Re: Warning: Avoid using dashes in column names!

TheDude
Level III

Re: Warning: Avoid using dashes in column names!

OK, I have now updated to JMP 17.1 and can confirm that this nasty bug has been fixed. 

 

No mention of this in the release notes of 17.1 (shame on SAS). 

 

So this is the solution. One should still be aware of this gotcha with column names. 

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Warning: Avoid using dashes in column names!

JMP took the route in it's syntax, to have as few "special" or "restricted" characters in naming variables or columns, etc.  The end re result is that it is possible that JMP will interpret an variable  or column name as a mathematical phrase, rather than a qualified name.  Thus, 

Col-1

would be evaluated as a variable named "Col" minus 1.

JMP has syntax that allows for the correct interpretation.

:"Col-1"n

tells JMP this is a column name and the column name is "Col-1".

Your Mean() function example is coded as

Mean( :"Col-1"n,  :"Col-2"n );
Jim
jthi
Super User

Re: Warning: Avoid using dashes in column names!

TheDude
Level III

Re: Warning: Avoid using dashes in column names!

Mmmhh... Ok. 

However, here's what I find in the formula editor for the second example:

Mean( As Column( "Col-2" ), As Column( "Col-1" ) )

So, what is the difference between As Column(colname) and :"colname"n?

What does the n at the end mean?

 

I think that such a rule about column name should be PAGE 1 of all tutorials on JMP tables, but there's nothis of that sort in all tutorials I have seen. 

TheDude
Level III

Re: Warning: Avoid using dashes in column names!

Never mind about the "n", it's explained at the links below. 

Re: Warning: Avoid using dashes in column names!

Were you building the formula interactively or typing it as a script?

 

I was not able to reproduce your results (in JMP 17.1) through an interactive building of the formula. I tried dragging the variables from the column list into the Mean function and got this:

Dan_Obermiller_0-1682450812679.png

And the calculation was correct (the JSL behind the interactive was

Mean(:"Col-1"n, :"Col-2"n)

 ). I also tried by selecting the boxes in the Mean formula and then choosing the variables from the variable list. That also worked.

 

If you are typing the code in, then as others have mentioned, you need to make sure you specify the column name properly. Interactively the names do not seem to be a problem.

Dan Obermiller
TheDude
Level III

Re: Warning: Avoid using dashes in column names!

Hi Dan, 

     I am using JMP 17.0.0 (622753). 

 

I have two columns with names Col-1 and Col-2. Go to new column, Properties, Formula, Edit Formula. 

Select Statistical > Mean. In the formula editor, I see Mean() with a blue box inside. Now I select both columns, and drag them into the box (+ sign appear). When I let go, I get Parse Errors dialog box. 

 

I then can close the error dialog and manually edit the box in script mode. 

 

Are you saying that you are not getting the Parse error in JMP 17.1?

Re: Warning: Avoid using dashes in column names!

I believe that I followed all of your steps and I do not get the Parse Errors dialog box. Maybe upgrading to 17.1 will fix your issue.

Dan Obermiller
TheDude
Level III

Re: Warning: Avoid using dashes in column names!

OK, I have now updated to JMP 17.1 and can confirm that this nasty bug has been fixed. 

 

No mention of this in the release notes of 17.1 (shame on SAS). 

 

So this is the solution. One should still be aware of this gotcha with column names.