cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Agustin
Level IV

Easy way of reordering columns

I have a script that reformats many files and performs some analysis producing a final summary table, however the order in which the calculations are done and new columns are added doesn't produce a very readable format.

I would like to pass the list of column names in the order I want them.

Is there a built - in way of doing this?

 

e.g. if I had a table with: Column 1, Column 2, Column 3, Column 4

 

I want to pass in the list {Column 2, Column 4, Column 1, Column 3} to the table and have the reorder the table columns to match.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Easy way of reordering columns

Here is the way I handle this.  By working backwards through the list, and moving each to the first position, the columns end up as you want them.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myList = {"age", "weight", "height"};
For( i = N Items( myList ), i >= 1, i--,
	Eval( Parse( "dt << Move Selected Columns(" || myList[i] || ", To first )" ) )
);
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Easy way of reordering columns

Here is the way I handle this.  By working backwards through the list, and moving each to the first position, the columns end up as you want them.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myList = {"age", "weight", "height"};
For( i = N Items( myList ), i >= 1, i--,
	Eval( Parse( "dt << Move Selected Columns(" || myList[i] || ", To first )" ) )
);
Jim
stan_koprowski
Community Manager Community Manager

Re: Easy way of reordering columns

Nice,  simple and clever solution @txnelson 

Agustin
Level IV

Re: Easy way of reordering columns

That's such an ingenious fix!

Recommended Articles