Subscribe Bookmark RSS Feed

How to handle quotation marks in column name when trying to use in dynamic formula


Community Trekker


Sep 5, 2012

Assume I have a table with headers Greek and AlsoGreek as follows:

Greek   AlsoGreek

Alpha       Phi

Beta         Omega

Gamma    Zeta

The following script will give me a column called "concat" which will combine the 2 columns (I added tabs between the concat symbols to make it more readable).

dt = Current Data Table();

colnames = dt<<get column names;

colstring=":Name(\!""     ||     char(colnames[1])     ||     "\!")";

colstring=colstring     ||     "||"     ||     ":Name(\!""     ||     char(colnames)     ||     "\!")"


dt<<new column("concat",formula(parsecolstring));

Now what's weird is if I put the table header AlsoGreek in quotes (as "AlsoGreek"), the code does not work.  Here's the output of the error log (I added show after all the variables in the above code so that I could see what was happening

colnames = {Greek, Name("\!"AlsoGreek\!"")};

Char(colnames[1]) = "Greek";

colstring = ":Name(\!"Greek\!")";

colstring = ":Name(\!"Greek\!")||:Name(\!"\!"AlsoGreek\!"\!")";

Expected ")", but found "AlsoGreek".

Line 1 Column 25: :Name("Greek")||:Name(""►AlsoGreek"")

Is there a solution for this?  If not, is there a way to extract the quotation marks from the column name?  I tried using substitute to remove the \!", but JMP doesn't recognize this as a string...

Any help would be greatly appreciated!  I have >100 columns with quotes in the column name...


Community Trekker


Sep 5, 2012

I guess I'll answer my own reply...

The problem is that JMP doesn't recognize which quotes are associated with the \!" and which ones aren't.  So my suspicion is that when you use a char function on a column with quotes, and then later tyr to parse it or do something else to that string, you'll run into issues.

There are 2 ways to handle this - the first way is to put all the columns you want to concatenate in a list, and then use the parse(concat(list)) option.

The other way (which is what I used) is to get the columns in a list, then remove the quotes using a simple for statement:



     insert into(noquotes,substitute(char(origlist),"\!"",""));

     as name(origlist<<set name(noquotes);


Use the noquotes list names to refer to the columns of interest, and after you're done, you can change the column names back to what they were originally by doing the reverse of the script above.


Community Trekker


Jun 23, 2011

It was hard for me to understand what you were trying to achieve. But, if you want to concatenate ALL ColumnNames in a JMP table, and create a new column with that newname, this code should work for your example:

By creating the variable NameofNewColumn, and using that in a New Column statement contained within the EVAL function....  might help you out.

dt = Current Data Table();

colnames = dt<<get column names;

NameofNewColumn = "";

For(i=1, i < N Items(colnames)+1, i++,

   NameofNewColumn = NameofNewColumn || Char(colnames);


eval(dt<<new column(NameofNewColumn)));