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

Name quote a strange column name

I'm trying to insert a column name into a fit model expression. For that I need to escape strange characters in column names to do that we use the :"name"n convention. So how do I go from a string column name to this format?

colListY = {"Plating Thickness (m\!"\!")"};
//This doesn't work
newcolumnref = eval insert("\[:"^colListY[1]^"n]\");

//Looking for this end result
:"Plating Thickness (m\!"\!")"n

Which I can then insert anywhere, for example:

insert into(expr(Y()), newcolumnref);

Anybody know of a robust way to do this?

22 REPLIES 22
hogi
Level XI

Re: Name quote a strange column name

 

dt = New Table( "plating",
	Add Rows( 4 ),
	New Column( "Plating Thickness (m\!"\!")",Set Values( [1, 2, 3, 4] )),
	New Column( "X",Set Values( [12, 26, 33, 39] ))
);
colListY = {"Plating Thickness (m\!"\!")"};


newcolumnref = Name Expr(AsColumn(colListY[1])); // -> :"String"n
Fit Model( //Y( :"Plating Thickness (m\!"\!")"n ), <- works //Y(column("Plating Thickness (m\!"\!"")), //<- does not work Y(newcolumnref), // <- works :) Effects(:X), Personality( "Standard Least Squares" ) );

from 
https://community.jmp.com/t5/Discussions/Need-help-with-expressions-column-references-formulas-and-c... 

Re: Name quote a strange column name

Names Default To Here( 1 );

dt = New Table( "plating",
	New Column( "Plating Thickness (m\!"\!")", Set Values( [1, 2, 3, 4] ) ),
	New Column( "X", Set Values( [12, 26, 33, 39] ) )
);

col = Column( dt, "Plating Thickness (m\!"\!")" );

Fit Model(
	Y( col ), // <- works :)
	Effects( :X ),
	Personality( "Standard Least Squares" ),
	Run
);
hogi
Level XI

Re: Name quote a strange column name

@Mark_Bailey 
Ah, so easy! great!!!

 

I was surprised to hear from @pauldeen :

https://community.jmp.com/t5/Discussions/Name-quote-a-strange-column-name/m-p/415735/highlight/true#...

that 


when building the fit model script the column() format cannot be used:

 

Fit Model(
	//Y( :"Plating Thickness (m\!"\!")"n ), <- works
	Y(column("Plating Thickness (m\!"\!"")), //<- does not work

OK, if it's like this, what would be the easiest solution to get the column without column() ...


Now I was surprised to see (by running your code) that it actually worked.
And went back to the old sniplet - and it didn't work.
Woah!

 

The puzzle gets solved if you put both lines of code exactly below each other:

hogi_1-1668610784363.png

-> So fortunately, no fancy non-Column() coding required for Fit Model.