<?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 Re: Code to Check If No Row Created in a of Data Table, Close the Data Table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415963#M66520</link>
    <description>&lt;P&gt;it work perfectly. Thanks&amp;nbsp;&lt;SPAN&gt;Jim and&amp;nbsp;Jarmo&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Sep 2021 12:50:06 GMT</pubDate>
    <dc:creator>bzanos</dc:creator>
    <dc:date>2021-09-07T12:50:06Z</dc:date>
    <item>
      <title>Code to Check If No Row Created in a of Data Table, Close the Data Table</title>
      <link>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415838#M66499</link>
      <description>&lt;P&gt;I am creating a list data table subset from a main data table. Then, I manipulate the data through Tabulate() and make into the table for processing. Then, check each of the data table N Rows, if N Rows = 0, close the data table. Finally, append the data table into the report. Below is my script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is after I add in below codes, to check the N Rows, it no longer work. No error show up.&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;If(N Rows(mDT)==0, Close(mDT, no save)); &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe might be some error on the code. The overall code might not be well written&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need guideline and help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;saveFolder = "$TEMP/";

listDT = {};
listtab = {};
mDT = {};

col = Column(dt1Sub, ":PART");

colLevs = Associative Array(col) &amp;lt;&amp;lt; Get Keys;

hb = V List Box( );

For (i=1, i&amp;lt;=NItems(colLevs), i++,

     r2get = dt1 &amp;lt;&amp;lt; Get Rows Where(:PART == colLevs[i]);

     listDT[i] = dt1 &amp;lt;&amp;lt; Subset(Rows(r2get));

     listDT[i] &amp;lt;&amp;lt; Set Name(Char(colLevs[i]));
 
     listDT[i] &amp;lt;&amp;lt; Save( saveFolder || Word( 1, listDT[i] &amp;lt;&amp;lt; get name, "-" )||".csv");
     
     listtab = listDT[i] &amp;lt;&amp;lt; Tabulate(
	               Show Control Panel( 0 ),
	               Add Table(
		               Column Table( Grouping Columns( :ORDER ) ),
		               Column Table( Statistics( Sum ), Analysis Columns( :Qty ) ),
		               Row Table(
			               Grouping Columns(
				              ::PART,
				              ::PART DESC,
				              :LOW PART #,
				              :LOW PART DESC,
				              :FAILURE MODE
			               )
		               )
	               )
                ); 
                
     mDT= listtab &amp;lt;&amp;lt; Make Into Data Table;   
     
     Close(listDT[i], no save);
    
     mDT &amp;lt;&amp;lt; New Column ("Criteria", Character, "Nominal",
     	      Formula(
     	      	If(As Column(6)&amp;gt;= 3, "Failure")
     	      )
     );
     mDT:Criteria &amp;lt;&amp;lt; Delete Formula;
     mDT &amp;lt;&amp;lt; Sort(By(Column(6)),Order(Descending), Replace Table);
     mDT &amp;lt;&amp;lt; Select Where (:As Column(6) == 0);
     mDT &amp;lt;&amp;lt; Delete Rows;
     
     If(N Rows(mDT)==0, Close(mDT, no save));   
          
     mDT &amp;lt;&amp;lt; Set Window Size (2400, 800);
     
     mDT &amp;lt;&amp;lt; Get As Report;
     
     hb &amp;lt;&amp;lt; Append( ( mDT &amp;lt;&amp;lt; Get As Report ) );
          
);

New Window( "Report", hb );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:56:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415838#M66499</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2023-06-09T19:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Check If No Row Created in a of Data Table, Close the Data Table</title>
      <link>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415860#M66501</link>
      <description>&lt;P&gt;It could be that you continue the loop execution after closing the datatable. You could try moving the rows in for loop after if-statement to else statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(N Rows(mDT) == 0,
	Close(mDT, no save)
,//else
	mDT &amp;lt;&amp;lt; Set Window Size(2400, 800);
	mDT &amp;lt;&amp;lt; Get As Report;
	hb &amp;lt;&amp;lt; Append((mDT &amp;lt;&amp;lt; Get As Report));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or useContinue() after closing mDT:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(N Rows(mDT) == 0,
	Close(mDT, no save)
	Continue();
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Sep 2021 17:02:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415860#M66501</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-09-06T17:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Check If No Row Created in a of Data Table, Close the Data Table</title>
      <link>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415864#M66503</link>
      <description>&lt;P&gt;You are attempting to pass messages to your mDT object even when the table has been closed.&amp;nbsp; See if the JSL below works for you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;saveFolder = "$TEMP/";

listDT = {};
listtab = {};
mDT = {};

col = Column( dt1Sub, ":PART" );

colLevs = Associative Array( col ) &amp;lt;&amp;lt; Get Keys;

hb = V List Box();

For( i = 1, i &amp;lt;= N Items( colLevs ), i++,
	r2get = dt1 &amp;lt;&amp;lt; Get Rows Where( :PART == colLevs[i] );
	listDT[i] = dt1 &amp;lt;&amp;lt; Subset( Rows( r2get ) );
	listDT[i] &amp;lt;&amp;lt; Set Name( Char( colLevs[i] ) );
	listDT[i] &amp;lt;&amp;lt; Save( saveFolder || Word( 1, listDT[i] &amp;lt;&amp;lt; get name, "-" ) || ".csv" );
	listtab = listDT[i] &amp;lt;&amp;lt; Tabulate(
		Show Control Panel( 0 ),
		Add Table(
			Column Table( Grouping Columns( :ORDER ) ),
			Column Table( Statistics( Sum ), Analysis Columns( :Qty ) ),
			Row Table(
				Grouping Columns(
					::PART, ::PART DESC, :LOW PART #, :LOW PART DESC, :FAILURE MODE
				)
			)
		)
	); 
                
	mDT = listtab &amp;lt;&amp;lt; Make Into Data Table;   
     
	Close( listDT[i], no save );
    
	mDT &amp;lt;&amp;lt; New Column( "Criteria",
		Character,
		"Nominal",
		Formula( If( As Column( 6 ) &amp;gt;= 3, "Failure" ) )
	);
	mDT:Criteria &amp;lt;&amp;lt; Delete Formula;
	mDT &amp;lt;&amp;lt; Sort( By( Column( 6 ) ), Order( Descending ), Replace Table );
	mDT &amp;lt;&amp;lt; Select Where( :As Column( 6 ) == 0 );
	mDT &amp;lt;&amp;lt; Delete Rows;
     
	If( N Rows( mDT ) == 0,
		Close( mDT, no save )
		, 	           
		mDT &amp;lt;&amp;lt; Set Window Size( 2400, 800 );
		mDT &amp;lt;&amp;lt; Get As Report;
		hb &amp;lt;&amp;lt; Append( (mDT &amp;lt;&amp;lt; Get As Report) );
	);
);

New Window( "Report", hb );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Sep 2021 17:10:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415864#M66503</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-09-06T17:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Check If No Row Created in a of Data Table, Close the Data Table</title>
      <link>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415963#M66520</link>
      <description>&lt;P&gt;it work perfectly. Thanks&amp;nbsp;&lt;SPAN&gt;Jim and&amp;nbsp;Jarmo&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 12:50:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Code-to-Check-If-No-Row-Created-in-a-of-Data-Table-Close-the/m-p/415963#M66520</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2021-09-07T12:50:06Z</dc:date>
    </item>
  </channel>
</rss>

