cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

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