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
ValeriaL
Level II

subset selection is empty, return error

Hi all,

I am writing a script where I select a subset from a data table based on some criteria:

Example dt is my data table with column :Error_ID

I input: "dt_subset=dt<<select where (:Error_ID==0)<<subset(selected rows(1));" and I expect the dt_subset table to be filled by all the entries in the dt table where the column :Error_ID is 0.

Now let us say the dt data table has no Error_ID==0 rows, the dt_subset is empty.

I would have expected an dt_subset to be a new data table with the same columns as table dt but 0 rows, so that if I then check whether "If( !Empty(dt_subset)...)" I get a false and I do not continue doing work on the empty dt_subset table.

Instead I get an error if I try to check the if dt_subset is empty.

 

Basically what I want to do is be able to check if the selection is empty. Do you have a solution?

 

Thank you for your help!

2 REPLIES 2
jthi
Super User

Re: subset selection is empty, return error

There are many different options You can check if selection is empty/no rows are found and then either use stop() or throw() to stop script execution (if it is suitable).

Names Default To Here(1);

dt = open("$SAMPLE_DATA/Big Class.jmp");

dt << Select Where(:age == 100);
// you can check for selections in dt table
If(N Items(dt << get selected rows) == 0,
	Show("No selections done");
);

dt_subset = dt << Subset(Selected Rows(1));
// you can check for dt_subset
If(Is Empty(dt_subset),
	Show("No subset table");
);

rows_to_subset = dt << Get Rows Where(:age == 100);
If(N Items(rows_to_subset) == 0,
	Show("No rows found");
);
// dt_subset = dt << Subset(rows(rows_to_subset));
-Jarmo
ValeriaL
Level II

Re: subset selection is empty, return error

Hi Jarmo,

thank you for your reply. I had finally time to check this and I see that the following solution worked:

 

dt_subset = dt << Subset(Selected Rows(1));
// you can check for dt_subset
If(Is Empty(dt_subset),
	Show("No subset table");
);

The other two still returned errors: 

ValeriaL_0-1673972285189.png

So I will use the second suggestion.

 

Best Regards, Valeria

Recommended Articles