<?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: Create a subset based on date filtering in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-a-subset-based-on-date-filtering/m-p/260937#M51089</link>
    <description>&lt;P&gt;So the script that you have will result in a defined start date, "sdt", and a defined end date, "edt".&lt;/P&gt;
&lt;P&gt;All you should need is a script to select rows in the table where the date is between sdt and edt.&lt;/P&gt;
&lt;P&gt;Then subset the selected rows.&lt;/P&gt;
&lt;P&gt;Take a look in the JMP Scripting Index. Help &amp;gt; Scripting Index. And look at the information and examples for Select Where and Subset.&lt;/P&gt;
&lt;P&gt;Here is an example from the index for Select Where:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Quality Control/Diameter.jmp" );
dt &amp;lt;&amp;lt; Process Screening(
	Y( :DIAMETER ),
	Grouping( :MACHINE, :Phase ),
	Select Where( Alarm Rate &amp;gt; 0 )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example from the index for Subset.&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; Subset(
	Rows(
		[28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want a script that will give you a subset table from the selected rows in a table, here is an example using the Big Class sample data set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Big Class" ) &amp;lt;&amp;lt; Subset(
	Selected Rows( 1 ),
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Open the Big Class data set from the sample data in JMP. Select some rows manually. Then run this script and see what happens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully all this helps.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Phil&lt;/P&gt;</description>
    <pubDate>Fri, 24 Apr 2020 10:21:49 GMT</pubDate>
    <dc:creator>Phil_Kay</dc:creator>
    <dc:date>2020-04-24T10:21:49Z</dc:date>
    <item>
      <title>Create a subset based on date filtering</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-subset-based-on-date-filtering/m-p/259790#M50978</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have a JMP data table on which I want to create a script to create a subset based on a timeframe I want to keep flexible.&lt;/P&gt;&lt;P&gt;Looking on the community I found the following piece of script (reported here below) which is good for me, I'm only missing the part of code where, after selecting the start date and end date the subset is created in a new datatable.&lt;/P&gt;&lt;P&gt;Someone can help me?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table ();

tmpstr =
"SELECT pen_parametric.pn_id, pen_parametric.equiplk_ky, parametric_dlk.paramlk_ky,
FROM MATS.parametric_dlk parametric_dlk, MATS.pen_parametric pen_parametric
WHERE parametric_dlk.paramlk_ky = parametric_ref_llk.paramlk_ky 
  AND parametric_dlk.paramlk_ky = pen_parametric.paramlk_ky 
   AND ((pen_parametric.part_dm Between {ts '^sdt^'} And {ts '^edt^'}))";

New Window( "Query Date",
	&amp;lt;&amp;lt;Modal, 
	sd = Today();
	ed = Today();
	H List Box(
		Text Box( "From:" ),
		scal = Number Edit Box( sd, &amp;lt;&amp;lt;Set Format( Format( "yyyy-mm-dd" ) ), &amp;lt;&amp;lt;SetFunction( Function( {this}, sd = scal &amp;lt;&amp;lt; Get ) ), &amp;lt;&amp;lt;Set Show Spin Box(1) ),
		Spacer Box( Size( 20, 20 ) ),
		Text Box( "To:" ),
		ecal = Number Edit Box( ed, &amp;lt;&amp;lt;Set Format( Format( "yyyy-mm-dd" ) ), &amp;lt;&amp;lt;SetFunction( Function( {this}, ed = ecal &amp;lt;&amp;lt; Get ) ), &amp;lt;&amp;lt;Set Show Spin Box(1) ),
	);
);

sdt = Munger( Format Date( sd, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " );
edt = Munger( Format Date( ed, "yyyy-mm-ddThh:mm:ss" ), 1, "T", " " ); 


Show( sdt, edt );
 
qstring = Eval Insert( tmpstr );
Show( qstring )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:46:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-subset-based-on-date-filtering/m-p/259790#M50978</guid>
      <dc:creator>js1985</dc:creator>
      <dc:date>2020-04-22T12:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset based on date filtering</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-subset-based-on-date-filtering/m-p/260937#M51089</link>
      <description>&lt;P&gt;So the script that you have will result in a defined start date, "sdt", and a defined end date, "edt".&lt;/P&gt;
&lt;P&gt;All you should need is a script to select rows in the table where the date is between sdt and edt.&lt;/P&gt;
&lt;P&gt;Then subset the selected rows.&lt;/P&gt;
&lt;P&gt;Take a look in the JMP Scripting Index. Help &amp;gt; Scripting Index. And look at the information and examples for Select Where and Subset.&lt;/P&gt;
&lt;P&gt;Here is an example from the index for Select Where:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Quality Control/Diameter.jmp" );
dt &amp;lt;&amp;lt; Process Screening(
	Y( :DIAMETER ),
	Grouping( :MACHINE, :Phase ),
	Select Where( Alarm Rate &amp;gt; 0 )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example from the index for Subset.&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; Subset(
	Rows(
		[28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want a script that will give you a subset table from the selected rows in a table, here is an example using the Big Class sample data set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Big Class" ) &amp;lt;&amp;lt; Subset(
	Selected Rows( 1 ),
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Open the Big Class data set from the sample data in JMP. Select some rows manually. Then run this script and see what happens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully all this helps.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 10:21:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-subset-based-on-date-filtering/m-p/260937#M51089</guid>
      <dc:creator>Phil_Kay</dc:creator>
      <dc:date>2020-04-24T10:21:49Z</dc:date>
    </item>
  </channel>
</rss>

