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

Deleting columns that are not in a list

Hi Guys,

I have a set of columns that I want to keep and then delete all except this set.

The columns that I want to delete are large in number.

Is there any easy way to do this using a script?

Thanks.
10 REPLIES 10
Von_Andre
Level II

Re: Deleting columns that are not in a list

Hi Dave, Appreciate all the help. Nice blog by the way! I have a very large data set consisting >8000 columns and I have some columns to keep and some don't. I ended up by using subset on the first columns that I want to keep. After which I run a loop on the rest of the table for keeping columns that matches from my keywords like "_M". Then finally join the subset and the table I had kept with column names matching my criteria. It works fine now. However, I then again try to use list on below code but seems not running. Is using of list not allowed on this? dt = Current Data Table(); // select data table dt << Set Name( "Raw_Data" ); dt << Subset( Columns( 1 :: 30 ), Rows( all ), Output Table( "Subset" ) ); // keep main column names dt << Revert(); //Keep vt columns colList = Data Table( "Raw_Data" ) << Get Column Names( String ); For( i = N Cols( dt ), i >= 1, i--, If( !Contains( colList[i], "_M" ), //Keep only columns with "_M"" in the name dt << Delete Column( Column( colList[i] ) ) ) );

Recommended Articles