<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic subset selection is empty, return error in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/584937#M79069</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am writing a script where I select a subset from a data table based on some criteria:&lt;/P&gt;&lt;P&gt;Example dt is my data table with column :Error_ID&lt;/P&gt;&lt;P&gt;I input: "dt_subset=dt&amp;lt;&amp;lt;select where (:Error_ID==0)&amp;lt;&amp;lt;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.&lt;/P&gt;&lt;P&gt;Now let us say the dt data table has no Error_ID==0 rows, the dt_subset is empty.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Instead I get an error if I try to check the if dt_subset is empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically what I want to do is be able to check if the selection is empty. Do you have a solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:05:27 GMT</pubDate>
    <dc:creator>ValeriaL</dc:creator>
    <dc:date>2023-06-09T16:05:27Z</dc:date>
    <item>
      <title>subset selection is empty, return error</title>
      <link>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/584937#M79069</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am writing a script where I select a subset from a data table based on some criteria:&lt;/P&gt;&lt;P&gt;Example dt is my data table with column :Error_ID&lt;/P&gt;&lt;P&gt;I input: "dt_subset=dt&amp;lt;&amp;lt;select where (:Error_ID==0)&amp;lt;&amp;lt;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.&lt;/P&gt;&lt;P&gt;Now let us say the dt data table has no Error_ID==0 rows, the dt_subset is empty.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Instead I get an error if I try to check the if dt_subset is empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically what I want to do is be able to check if the selection is empty. Do you have a solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:05:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/584937#M79069</guid>
      <dc:creator>ValeriaL</dc:creator>
      <dc:date>2023-06-09T16:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: subset selection is empty, return error</title>
      <link>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/584960#M79070</link>
      <description>&lt;P&gt;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).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = open("$SAMPLE_DATA/Big Class.jmp");

dt &amp;lt;&amp;lt; Select Where(:age == 100);
// you can check for selections in dt table
If(N Items(dt &amp;lt;&amp;lt; get selected rows) == 0,
	Show("No selections done");
);

dt_subset = dt &amp;lt;&amp;lt; Subset(Selected Rows(1));
// you can check for dt_subset
If(Is Empty(dt_subset),
	Show("No subset table");
);

rows_to_subset = dt &amp;lt;&amp;lt; Get Rows Where(:age == 100);
If(N Items(rows_to_subset) == 0,
	Show("No rows found");
);
// dt_subset = dt &amp;lt;&amp;lt; Subset(rows(rows_to_subset));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Dec 2022 21:02:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/584960#M79070</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-12-22T21:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: subset selection is empty, return error</title>
      <link>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/590511#M79500</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;&lt;P&gt;thank you for your reply. I had finally time to check this and I see that the following solution worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;dt_subset = dt &amp;lt;&amp;lt; Subset(Selected Rows(1));
// you can check for dt_subset
If(Is Empty(dt_subset),
	Show("No subset table");
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The other two still returned errors:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ValeriaL_0-1673972285189.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49198i22B6108763C17989/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ValeriaL_0-1673972285189.png" alt="ValeriaL_0-1673972285189.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I will use the second suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards, Valeria&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:18:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/subset-selection-is-empty-return-error/m-p/590511#M79500</guid>
      <dc:creator>ValeriaL</dc:creator>
      <dc:date>2023-01-17T16:18:42Z</dc:date>
    </item>
  </channel>
</rss>

