cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

how to find the empty columns and delete them by scripting

how to find the empty columns and delete them by scripting. any helps and/or hints will be very appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: how to find the empty columns and delete them by scripting

I can think of several ways to do this. Here's an example based on the built-in Missing Data Pattern command.

dt = Current Data Table();

names = dt << Get Column Names();

dt1 = dt << Missing Data Pattern(columns(Eval(names)), invisible);

n = N Row(dt1);

For(i = N Col(dt), i >= 1, i--,

    If(Col Sum(Column(dt1, i + 3)) < n,

        Remove From(names, i)

    )

);

Try(dt << delete columns(names));

Close(dt1, nosave);

View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: how to find the empty columns and delete them by scripting

I can think of several ways to do this. Here's an example based on the built-in Missing Data Pattern command.

dt = Current Data Table();

names = dt << Get Column Names();

dt1 = dt << Missing Data Pattern(columns(Eval(names)), invisible);

n = N Row(dt1);

For(i = N Col(dt), i >= 1, i--,

    If(Col Sum(Column(dt1, i + 3)) < n,

        Remove From(names, i)

    )

);

Try(dt << delete columns(names));

Close(dt1, nosave);

ian_jmp
Level X

Re: how to find the empty columns and delete them by scripting

As an alternative (and probably one of Marcus' 'several ways'):

dt = CurrentDataTable();

m = dt << getAllColumnsAsMatrix;

// Loop over the columns and record which are entirely missing

c2del = {};

for(c=1, c<=NCol(m), c++,

if(NRow(Loc(IsMissing(m[0,c]))) == NRow(m), InsertInto(c2del, c));

);

// Delete the columns

dt << deleteColumns(c2del);

Recommended Articles