cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
OneNorthJMP
Level V

JSL how to rename column name by expression

Hi,

 

I have a list of of columns name that generated by Summary statistic. I want to remove all the prefix and sufix that only keep the part that i want. how do i do this in JSL? 

 

Columns

% of Total(UP9019-01) => UP9019-01

% of Total(UP9019-02) => UP9019-02

% of Total(UP9019-03) => UP9019-03

.....

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL how to rename column name by expression

The first way I would handle this, is to have the Summary Platform name the output column as the same as the input column name.  This is done by specifying

     statistics column name format( "column" )

This is selectable from the Summary Platform Input Dialog Box

 

If you can not do this, then all that has to be done is to reset the column name using this JSL

:Name("% of Total(UP9010-01)") << set name( "UP9019-01: );

If this needs to be automated and not hard coded, and this column is the first column in the data table, it could be handled with this JSL

column(1) << set name(word(2,column(1)<<get name,"()"))
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: JSL how to rename column name by expression

The first way I would handle this, is to have the Summary Platform name the output column as the same as the input column name.  This is done by specifying

     statistics column name format( "column" )

This is selectable from the Summary Platform Input Dialog Box

 

If you can not do this, then all that has to be done is to reset the column name using this JSL

:Name("% of Total(UP9010-01)") << set name( "UP9019-01: );

If this needs to be automated and not hard coded, and this column is the first column in the data table, it could be handled with this JSL

column(1) << set name(word(2,column(1)<<get name,"()"))
Jim
OneNorthJMP
Level V

Re: JSL how to rename column name by expression

Hi Nelson,

Thanks for the tips. 1st option that specifying statics column name format ("column") does not work. It still carry the % of Total in the table.

JSL option that you suggest work perfectly!

ColList = dt_source << get column names( string );
//% of Total(UP9019-01)
For( i = 4, i <= N Items( ColList ), i++,
    Column( i ) << set name( Word( 2, Column( i ) << get name, "()" ) )
);
txnelson
Super User

Re: JSL how to rename column name by expression

Here is a simple example using the "statistics column name format( "column" )" option, showing the % of Total columns named their original column name

stat.PNG

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

Data Table( "big class" ) << Summary(
	Group( :age ),
	Name( "% of Total" )(:height),
	Name( "% of Total" )(:weight),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
Jim
OneNorthJMP
Level V

Re: JSL how to rename column name by expression

Hi Nelson,

Statistic column name will work if you didn't use subgroup. In my case, i need to use subgroup. % of Total will still attached to the subgroup