cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
mwyant
Level I

Remove rows with one or more empty values using JSL

I have a table where each row contains a single measurement type at three temperatures, each stored in its own column. Ultimately, I want to calculate the deltas between these measurements and then stack that data into a new table. However, not all measurements are taken at all three temperatures, and I need to exclude those measurements (rows) where one or more of the data columns are empty. I need to do this using a JMP 9.0 script.

Given:

dtSplit =

MeasurementT1T2T3
Measurement A51289
Measurement B138
Measurement C5257
Measurement D2221
Measurement E8
Measurement F15
Measurement G54

I need to produce:

dtClean =

MeasurementT1T2T3
Measurement A51289

I was trying to use something like:

dtSplit << Select Where(
     Is Empty(:T1) ||
     Is Empty(:T2) ||
     is Empty(:T3)
) << Delete Rows;

However, any Select Where(Is Empty(:COL)) always selects all rows.

I'm sure I am missing something simple, your help is greatly appreciated, thanks,

- Matt

12 REPLIES 12
txnelson
Super User

Re: Remove rows with one or more empty values using JSL

You need to look into the Missing Data Pattern platform.  It will allow you to identify all of the rows that have all missing values, and then you can choose to delete the rows, etc.

      Tables==>Missing Data Pattern

Jim
new_2_JMP
Level I

Re: Remove rows with one or more empty values using JSL

Hi

Thanks for the input. Checked out the Missing  Data Pattern you recommended and it sort of works but not fully. 

In my data table, each name has 4 different rows. Each of the 4 row of a name is a result of 1 test (sens, mask, EVM and power)

In my data table example, device A fails the first test "Sens" and passes the 2nd, 3rd and 4th test. Because device A fails "Sens", this is a fail device even though it passes the 2nd, 3rd and 4th test. 

If I use Tables==>Missing Data Pattern, then 2nd, 3rd and 4th rows of A will be deleted. Which is not what I am looking for. I want to delete 4 rows of each name when there are no data on them ( no data on 10 MHz, 20 MHz, 30 MHz and 1000 MHz). In my data table, names C, G, H, I, J K and N will be deleted.

 

Thanks for your helps

 

 

 

SpannerHead
Level VI

Re: Remove rows with one or more empty values using JSL

This script will start working after the column titled "Names" and continue to the end of the table deleting empty rows.

 

// Get the current data table
dt = Current Data Table();

// Get all column names as strings
cnmes = dt << Get Column Names("string");

// Initialize Start and End indices
Start = .;
End = N Items(cnmes);

// Find the index of the "Device 2" column
For(k = 1, k <= N Items(cnmes), k++,
    If(Contains(cnmes[k], "Names"),
        Start = k + 1;
        Break(); // Exit loop once found
    );
);

// Loop through the columns from Start to End and delete rows with missing values
For(i = Start, i <= End, i++,
    dt << Select Where(Is Missing(Column(i)[])) << Delete Rows;
);

Slán



SpannerHead

Recommended Articles