If I'm reading your message correctly, I think you've actually got two questions.
- How to find the rows that are all missing for a given set of columns.
- How to make your code not dependent on the names of those columns and how many there are.
Not surprisingly there are lots of different ways to do 1. PMroz , MS and Craige@JMP have given you some options there.
I'll throw in one more. You could use the Missing Data Pattern utility to find them.
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//I want to use the columns starting at column 9,
//so I build a list of references to them
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
mdp = Dt << Missing Data Pattern( columns( Eval( mycols ) ), Output Table( "Missing Data Pattern" ) );
//The patterns columns shows the pattern of missing values
//the Missing Data Pattern data table is sorted,
//so if there are rows with all missing data
//the last row of the Missing Data Pattern data table will be all 1s.
//The Repeat() function just builds a string of 1s for as many columns as I'm working with
If( Column( mdp, "Patterns" )[N Rows( mdp )] == Repeat( "1", N Items( mycols ) ),
//The Missing Data Pattern data table is linked to the source table so selecting a row
//in it, selects all the rows that it represents in the source table
mdp << Select Rows( N Rows( mdp ) );
//now I can delete the rows in the source table
dt << delete rows;
,
Show( "No all missing rows" )
);
I've tried to show how to make this code work for any number of columns. In this case, because I needed a list of columns to pass to the Missing Data Pattern utility, I built a list based on the column numbers.
Even having written all of this and having shown how to use the Missing Data Pattern Utility, I think my favorite solution here would be PMroz's to use Stack Columns. You really want to end up with the data stacked anyway, so doing that first makes it easy to simply select the missing rows in the stacked column and delete them.
dt = Open( "$SAMPLE_DATA\Cities.jmp" );
//delete some columns from this table to make it fit your example
dt << delete columns( "PM10", "X", "Y" );
//change name of data table to ensure this modified version doesn't get saved
//over the sample data
dt << set name( "CitiesModified" );
//again I need a list of columns to use in the Stack()
mycols = {};
For( i = 9, i <= N Cols( dt ), i++,
Insert Into( mycols, Column( dt, i ) )
);
//stack those columns creating a new data table
stacked_dt = dt << Stack(
columns( Eval( mycols ) ),
Source Label Column( "Gas" ),
Stacked Data Column( "PPM" )
);
missing_rows = stacked_dt << get rows where( Is Missing( :PPM ) );
stacked_dt << delete rows( missing_rows );
-Jeff