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
bordini
Level III

Change column names at once

Hello,

 

I have a data table with several continuous columns, each column with a different name. I wish to: 1) duplicate continuous columns all at once; 2) rename these new columns with their original names (i.e., lady beetle) plus add "/100" to their names (i.e., column name would be: lady beetle/100) all at once; then 3) I want to multiply these new columns by 4 all at once (only the continuous columns).

Could anyone can help me with a script that could do these three things, please?

 

I'm using JMP 16.1 (MacBook).

 

Thank you!

 

Here is an example of how my data looks like, but I have several continuous columns:

Screen Shot 2022-10-19 at 2.00.18 PM.png

 

 

 

 

 

3 REPLIES 3
txnelson
Super User

Re: Change column names at once

Here is how I would solve the problem.  The only issue with this code, is the determination of what columns to process.  Assuming that Date and Process Date are JMP Date columns, they are continuous columns and therefore have to be deleted from the processing.

Names Default To Here( 1 );

dt = Current Data Table();

cols = dt << get column names( string, continuous );
Remove From( cols, 1, 1 );
Remove From( cols, N Items( cols ), 1 );

dtTemp = dt << subset( selected rows( 0 ), columns( cols ) );

dtTemp[0, 0] = dtTemp[0, 0] * 4;

For Each( {name}, cols,
	Column( dtTemp, name ) << set name( (Column( dtTemp, name ) << get name) || "/100" )
);

dt << Update( With( dtTemp ) );

Close( dtTemp, nosave );
Jim
hogi
Level XII

Re: Change column names at once

without JSL?

via Custom Column transformations from @ih's add-in collection:
https://community.jmp.com/t5/JMP-Add-Ins/Scripting-Tools/ta-p/410943#U410943 

here is a wish to include this add-in collection in standard JMP:
https://community.jmp.com/t5/JMP-Wish-List/Custom-Transformation/idi-p/412010 

hogi_0-1666281555266.png

 

hogi
Level XII

Re: Change column names at once

The easies way to rescale multiple columns at once: select the columns - right click - New Formula Column - Transform - Scale Offset ...

 

hogi_2-1666540671827.png

 




please note the meaningnful names of the new columns
If you want to change it to (... /100), you could do it manually or use @ih' s Rename Columns AddIn:
https://community.jmp.com/t5/JMP-Add-Ins/Scripting-Tools/ta-p/410943#U410943 

hogi_1-1666540386032.png