Hi,
I am new to JSL Scripting.
Is there a way I could number all the columns using a jsl script? There are 100 columns in the data table and I want to concatenate number in the column names
On example, there are multiples columns that follow this type:-
Looking for some feedback
Thanks,
Jay
Hi @Jackie_ ,
You could use a short script to do this:
Names default to here(1);
dt = Open("$Sample_data/iris.jmp");
cols = dt << Get column names;
for(c = 1, c<= n items(cols), c++,
Column(dt, c) << Set Name( char(c) || ". " || ( Column(dt, c) << Get Name ) )
);
Hi @Jackie_ ,
You could use a short script to do this:
Names default to here(1);
dt = Open("$Sample_data/iris.jmp");
cols = dt << Get column names;
for(c = 1, c<= n items(cols), c++,
Column(dt, c) << Set Name( char(c) || ". " || ( Column(dt, c) << Get Name ) )
);
Thanks, @ih
I want to assign numbers only to a particular group of columns.
For eg: In this case, I want to serialize the column group "Tests". There are more than 100 columns in the tests groups. Please can you help me with the jsl?
Many thanks,
Jack
If you are working interactively then the function get selected columns might help:
Names default to here(1);
dt = Open("$Sample_data/iris.jmp");
dt:Sepal length << Set Selected(1);
dt:Sepal width << Set Selected(1);
cols = dt << Get selected columns;
for(c = 1, c<= n items(cols), c++,
Column(dt, c) << Set Name( char(c) || ". " || ( Column(dt, c) << Get Name ) )
);
Otherwise you could include an if statement in the for loop to ensure the name matches whatever criteria you have.
If you are using JMP16 you could also try with Transform Each (or For Each):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Transform Each({value, idx}, dt << Get Column Names("String"),
Column(dt, value) << Set Name(Char(idx) ||". " || value);
);
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
Column( dt, i ) << set name( Char( i ) || ". " || Char( Column( dt, i ) << get name ) )
);