<?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: Creating a script to select only certain values related to specific date range in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822759#M100252</link>
    <description>&lt;P&gt;Welcome to the Community.&lt;/P&gt;
&lt;P&gt;The actual statements that will select rows within a given date range and create a new data table with just those selected rows included.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Select the row that have the date range desired
dt &amp;lt;&amp;lt; select where( :Start Date &amp;gt;= informat("01/10/2025","m/d/y") &amp;amp; 
	:End Date &amp;lt;= informat("04/30/2025","m/d/y"));
// Create the new table
dtSubset = dt &amp;lt;&amp;lt; subset( selected columns(0), selected rows(1), output table("theSubset"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is a full example that first creates an example data table, and then runs the above lines to select and create the data table.&lt;/P&gt;
&lt;P&gt;(Note:&amp;nbsp; Below example was somehow left out of original posting. Thanks to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;for heads up on the omission )&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create an Example data table
dt = New Table( "Example",
	Add Rows( 20 ),
	New Column( "Start Date",
		Format( "m/d/Y" ),
		set each value( Today() + In Days( Random Integer( 1, 100 ) ) )
	),
	New Column( "End Date",
		Format( "m/d/Y" ),
		set each value( :Start Date + In Days( Random Integer( 1, 50 ) ) )
	)
);

// Select the row that have the date range desired
dt &amp;lt;&amp;lt; select where(
	:Start Date &amp;gt;= Informat( "01/10/2025", "m/d/y" ) &amp;amp; :End Date &amp;lt;=
	Informat( "04/30/2025", "m/d/y" )
);
// Create the new table
dtSubset = dt &amp;lt;&amp;lt; subset(
	selected columns( 0 ),
	selected rows( 1 ),
	output table( "theSubset" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another interesting, interactive way to create the new table is to use a Data Filter. The Data Filter allows the user to interactively select rows in the data table, and once the desired rows are selected, a new table from those rows can be created.&lt;/P&gt;
&lt;P&gt;To to this: Once the data table is displayed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1734155158308.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71203i9258F85797D12339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1734155158308.png" alt="txnelson_1-1734155158308.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Go to the Rows pull down menu and select "Data Filter"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1734155406295.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71204i3910FEA1A2DB4A5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_2-1734155406295.png" alt="txnelson_2-1734155406295.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the Data Filter window, select the Start and End Dates, and Click on the + sign&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_3-1734155523668.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71205i7817AC43DB80741E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_3-1734155523668.png" alt="txnelson_3-1734155523668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Filters will then be displayed.&lt;/P&gt;
&lt;P&gt;Click on the Show and Include check boxes.&amp;nbsp; The indicate the action to take on the rows in the data table when the setting for the filters select the rows.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_4-1734155694846.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71206iB43DE0BCE5444CF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_4-1734155694846.png" alt="txnelson_4-1734155694846.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now the Filters can be set to make the selection.&amp;nbsp; The blue lines can be dragged to the desired Star and End Dates, or the values can be directly typed in in the displayed date area for each filter.&lt;/P&gt;
&lt;P&gt;Please note how the rows in the data table become selected as the filters are changed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_5-1734156015619.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71207i1C37D77FBC94159D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_5-1734156015619.png" alt="txnelson_5-1734156015619.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Once the desired rows are selected a new data table can be created by selecting the Show Subset selection from the Data Filter red triangle's list of actions.&amp;nbsp; Just click on the red triangle beside the Data Filter title and select the option&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_6-1734156239580.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71208iAD6BEA7071F940D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_6-1734156239580.png" alt="txnelson_6-1734156239580.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_7-1734156306378.png" style="width: 589px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71209iF4EEB125BF6B839A/image-dimensions/589x358?v=v2" width="589" height="358" role="button" title="txnelson_7-1734156306378.png" alt="txnelson_7-1734156306378.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Dec 2024 11:52:55 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2024-12-14T11:52:55Z</dc:date>
    <item>
      <title>Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822741#M100251</link>
      <description>&lt;P&gt;I was given a file similar to this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PruningTheSpark_0-1734151299506.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71201iF61E18720568D4F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PruningTheSpark_0-1734151299506.png" alt="PruningTheSpark_0-1734151299506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I was asked to create a formula that pulls all the codes that happened between the start and stop dates.&amp;nbsp; I'm unsure how to set this up as a formula.&amp;nbsp; Is this something that could be created as a script to pull all the codes that occur between the start and stop dates?&amp;nbsp; I have never set up a script before and hoping someone can walk me through how to create one.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 04:44:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822741#M100251</guid>
      <dc:creator>PruningTheSpark</dc:creator>
      <dc:date>2024-12-14T04:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822759#M100252</link>
      <description>&lt;P&gt;Welcome to the Community.&lt;/P&gt;
&lt;P&gt;The actual statements that will select rows within a given date range and create a new data table with just those selected rows included.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Select the row that have the date range desired
dt &amp;lt;&amp;lt; select where( :Start Date &amp;gt;= informat("01/10/2025","m/d/y") &amp;amp; 
	:End Date &amp;lt;= informat("04/30/2025","m/d/y"));
// Create the new table
dtSubset = dt &amp;lt;&amp;lt; subset( selected columns(0), selected rows(1), output table("theSubset"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is a full example that first creates an example data table, and then runs the above lines to select and create the data table.&lt;/P&gt;
&lt;P&gt;(Note:&amp;nbsp; Below example was somehow left out of original posting. Thanks to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;for heads up on the omission )&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create an Example data table
dt = New Table( "Example",
	Add Rows( 20 ),
	New Column( "Start Date",
		Format( "m/d/Y" ),
		set each value( Today() + In Days( Random Integer( 1, 100 ) ) )
	),
	New Column( "End Date",
		Format( "m/d/Y" ),
		set each value( :Start Date + In Days( Random Integer( 1, 50 ) ) )
	)
);

// Select the row that have the date range desired
dt &amp;lt;&amp;lt; select where(
	:Start Date &amp;gt;= Informat( "01/10/2025", "m/d/y" ) &amp;amp; :End Date &amp;lt;=
	Informat( "04/30/2025", "m/d/y" )
);
// Create the new table
dtSubset = dt &amp;lt;&amp;lt; subset(
	selected columns( 0 ),
	selected rows( 1 ),
	output table( "theSubset" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another interesting, interactive way to create the new table is to use a Data Filter. The Data Filter allows the user to interactively select rows in the data table, and once the desired rows are selected, a new table from those rows can be created.&lt;/P&gt;
&lt;P&gt;To to this: Once the data table is displayed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1734155158308.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71203i9258F85797D12339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1734155158308.png" alt="txnelson_1-1734155158308.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Go to the Rows pull down menu and select "Data Filter"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1734155406295.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71204i3910FEA1A2DB4A5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_2-1734155406295.png" alt="txnelson_2-1734155406295.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the Data Filter window, select the Start and End Dates, and Click on the + sign&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_3-1734155523668.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71205i7817AC43DB80741E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_3-1734155523668.png" alt="txnelson_3-1734155523668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Filters will then be displayed.&lt;/P&gt;
&lt;P&gt;Click on the Show and Include check boxes.&amp;nbsp; The indicate the action to take on the rows in the data table when the setting for the filters select the rows.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_4-1734155694846.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71206iB43DE0BCE5444CF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_4-1734155694846.png" alt="txnelson_4-1734155694846.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now the Filters can be set to make the selection.&amp;nbsp; The blue lines can be dragged to the desired Star and End Dates, or the values can be directly typed in in the displayed date area for each filter.&lt;/P&gt;
&lt;P&gt;Please note how the rows in the data table become selected as the filters are changed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_5-1734156015619.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71207i1C37D77FBC94159D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_5-1734156015619.png" alt="txnelson_5-1734156015619.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Once the desired rows are selected a new data table can be created by selecting the Show Subset selection from the Data Filter red triangle's list of actions.&amp;nbsp; Just click on the red triangle beside the Data Filter title and select the option&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_6-1734156239580.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71208iAD6BEA7071F940D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_6-1734156239580.png" alt="txnelson_6-1734156239580.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_7-1734156306378.png" style="width: 589px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71209iF4EEB125BF6B839A/image-dimensions/589x358?v=v2" width="589" height="358" role="button" title="txnelson_7-1734156306378.png" alt="txnelson_7-1734156306378.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 11:52:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822759#M100252</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-12-14T11:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822762#M100255</link>
      <description>&lt;P&gt;Could you provide example table to make it a bit easier to create an example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wouldn't most likely create a formula for this but rather a script. I assume you wish to extract all code_x values in which date_x falls between start date and end date for each row? Where should they be recorded? What should be done to duplicates? Can data format be changed (could the data be stacked)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt; did JMP community drop your full example?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 07:19:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822762#M100255</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-14T07:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822817#M100276</link>
      <description>&lt;P&gt;This is an example table to use.&amp;nbsp; You are correct, I need to look at each row and get the codes for each date between the start and end dates.&amp;nbsp; It doesn't matter if there are duplicates.&amp;nbsp; Ultimately, I need to know if all the codes are the same, or if there are different codes in each time frame.&amp;nbsp; I need to know for each row if the codes that fall between the start and stop dates are all "2"s or all " 3"s or a combination of the codes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this must need to be some sort of script as I cannot think of a formula that will work.&amp;nbsp; I have no experience creating scripts so any help would be appreciated!!&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 07:41:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822817#M100276</guid>
      <dc:creator>PruningTheSpark</dc:creator>
      <dc:date>2024-12-15T07:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822819#M100277</link>
      <description>&lt;P&gt;This can be most likely made much simpler with your final need in mind, but as there is no exact specification / result column I just created something I think should help you forward&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/example table.jmp");
Try(Column(dt, "Date 1") &amp;lt;&amp;lt; Set Name("date_1"));

date_cols = Filter Each({colname}, dt &amp;lt;&amp;lt; Get Column Names("String"),
	Starts With(colname, "date_");
);
code_cols = Filter Each({colname}, dt &amp;lt;&amp;lt; Get Column Names("String"),
	Starts With(colname, "code ");
);

dt &amp;lt;&amp;lt; New Column("Result", Character, Multiple Response);

For Each Row(dt,
	dates = dt[Row(), date_cols];
	between_bin = :"Start date"n &amp;lt;= dates &amp;lt;= :"Stop date"n;
	between_idx = Loc(between_bin);
	If(N Items(between_idx) &amp;gt; 0,
		codes = dt[Row(), code_cols[between_idx]];
		valid = Loc(codes);
		If(N Items(valid) == 0,
			codes = {};
		,
			codes = As List(codes[valid`]);
		);
	,
		codes = {};
	);

	res = Transform Each({code}, codes,
		Char(code);
	);
	
	:Result = Concat Items(res, ", ");
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1734254499524.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71226iF1531852724024C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1734254499524.png" alt="jthi_0-1734254499524.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 09:21:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/822819#M100277</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-15T09:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823039#M100280</link>
      <description>&lt;P&gt;Jarmo's code is spectacular.&amp;nbsp; I enjoy seeing how he approaches and solves problems. But, for most of my life, I have been considered by my collogues, friends, spouse and children as being strange in thought.&amp;nbsp; On good days, I am referred to as a "Nerd".&lt;/P&gt;
&lt;P&gt;So given my status in life, I have found out that most people do not think the way I do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/63204"&gt;@PruningTheSpark&lt;/a&gt;&amp;nbsp; states&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I think this must need to be some sort of script as I cannot think of a formula that will work.&amp;nbsp; I have no experience creating scripts so any help would be appreciated!!&lt;/SPAN&gt;".&lt;/P&gt;
&lt;P&gt;I believe that a majority of JMP users fall close to PruningTheSpark's position. PruningTheSpark may not think there is a non scripting solution to the problem, but JMP's interactive capabilities to manipulate one's data are really powerful.&amp;nbsp; So below I have put together the interactive steps it takes to solve PruningTheSparks issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Starting with the sample data table that was provided, I did modify it slightly.&amp;nbsp; Given the results from Jamo's script, it shows that none of the rows have more than one valid code.&amp;nbsp; Given that more than one code is a potential, I added in&amp;nbsp; code on row 2 that would show up for row 2 to have multiple codes.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1734273699807.png" style="width: 903px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71229i990A1E860CA8B0EB/image-dimensions/903x79?v=v2" width="903" height="79" role="button" title="txnelson_1-1734273699807.png" alt="txnelson_1-1734273699807.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The first task is to find all of the codes that fall within the Start Date and Stop Date.&amp;nbsp; Since there are 6 different code columns, the easiest way to do this all at once is to stack the data .&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Stack&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1734273947931.png" style="width: 763px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71230i1F1FC66F83626A3D/image-dimensions/763x417?v=v2" width="763" height="417" role="button" title="txnelson_2-1734273947931.png" alt="txnelson_2-1734273947931.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It is a Multiple series stack, staking the date and the code columns&lt;/P&gt;
&lt;P&gt;Now I can get rid of all codes that have missing values since they will not figure into the results.&amp;nbsp; So I selected one cell that has a missing value in the Data 2 column which contains all of the codes and then right click and choose Select Mating Cells&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_3-1734274329802.png" style="width: 617px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71231i394C7C037709DC33/image-dimensions/617x259?v=v2" width="617" height="259" role="button" title="txnelson_3-1734274329802.png" alt="txnelson_3-1734274329802.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which selects all of the rows that have missing values for column Data 2.&lt;/P&gt;
&lt;P&gt;Right click in the RowState column and select Delete Rows&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_4-1734274493918.png" style="width: 576px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71232i677E90B3EA939ED7/image-dimensions/576x428?v=v2" width="576" height="428" role="button" title="txnelson_4-1734274493918.png" alt="txnelson_4-1734274493918.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and you are left with only the rows that have codes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_5-1734274620789.png" style="width: 594px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71233iB9D3F821D36CDB33/image-dimensions/594x322?v=v2" width="594" height="322" role="button" title="txnelson_5-1734274620789.png" alt="txnelson_5-1734274620789.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now I need to determine which of these codes fall within the Start Date and the Stop Date.&amp;nbsp; For this I am just going to create a new&amp;nbsp; column, which I will call "in between" which has a formula of&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1734275157461.png" style="width: 623px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71235iD694E55446DF2C9B/image-dimensions/623x278?v=v2" width="623" height="278" role="button" title="txnelson_0-1734275157461.png" alt="txnelson_0-1734275157461.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;which has a 1 for rows where the column Data (it contains the Date from the original table) has a 1 for being in the range and a 0 for being outside of the range&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1734275281443.png" style="width: 653px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71236i9677FA7A689723A0/image-dimensions/653x341?v=v2" width="653" height="341" role="button" title="txnelson_1-1734275281443.png" alt="txnelson_1-1734275281443.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Using the same technique as when deleting the codes with a missing value, the rows with zeros can be selected and deleted&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1734275419804.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71237iA83CB151E5046F9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_2-1734275419804.png" alt="txnelson_2-1734275419804.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To clean up the table, some of the no longer needed columns can be deleted&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_3-1734275591364.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71238iA9013455DA18167F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_3-1734275591364.png" alt="txnelson_3-1734275591364.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now the task is to get the codes back into single rows.&amp;nbsp; To do this, a simple Split can be done&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Split&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_4-1734275732612.png" style="width: 651px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71239i5F3B6EE1A30C2BC4/image-dimensions/651x398?v=v2" width="651" height="398" role="button" title="txnelson_4-1734275732612.png" alt="txnelson_4-1734275732612.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_5-1734275823204.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71240i5D838C7D05AE5C88/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_5-1734275823204.png" alt="txnelson_5-1734275823204.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now to combine the code columns into one column, a Column Utility called Combine Columns can be used.&amp;nbsp; Just select the columns that are to be combined and then&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Cols=&amp;gt;Utility=&amp;gt;Combine Columns&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_6-1734275995990.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71241iE99CB966BB02BCDD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_6-1734275995990.png" alt="txnelson_6-1734275995990.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which pops up an input box to fill in the name of the new column, and what delimiter to&amp;nbsp; place between items, in this case, a ","&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_7-1734276158965.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71242i8F425C57CCBE0AB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_7-1734276158965.png" alt="txnelson_7-1734276158965.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;this results in the table having a new column&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_8-1734276210733.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71243iFEA742BE6A86F1BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_8-1734276210733.png" alt="txnelson_8-1734276210733.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Clean up on the table by deleting the no longer needed columns gives&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_9-1734276283410.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71244iF7849B001B786617/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_9-1734276283410.png" alt="txnelson_9-1734276283410.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now all that has to be done, is to move the results back into the original data table.&amp;nbsp; To do this, the Update platform will do the trick.&amp;nbsp; Click on the original table and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Update&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_10-1734276458194.png" style="width: 889px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71245i133D4CB105203024/image-dimensions/889x411?v=v2" width="889" height="411" role="button" title="txnelson_10-1734276458194.png" alt="txnelson_10-1734276458194.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Fill in the table to get the update from, and select to match record_id of the original table with record_id from the Split table and click on OK and the original table will contain are solution&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_11-1734276643313.png" style="width: 896px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71246i4AC900F66D5D4667/image-dimensions/896x233?v=v2" width="896" height="233" role="button" title="txnelson_11-1734276643313.png" alt="txnelson_11-1734276643313.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;No script was used, only 2 simple formula columns were required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, as one goes through these steps, JMP places in the log, the JSL required to create the interactive steps that were run.&amp;nbsp; So one can simply copy those pieces of JSL into a script, and at the end have a script that when run will great the solution in the blink of an eye.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt = data table( "Example Table" );

// Stack data table
// → Data Table( "Stacked" )
dtStacked = Data Table( "example table" ) &amp;lt;&amp;lt; Stack(
	columns(
		:date_1, :code 1, :date_2, :code 2, :date_3, :code 3, :date_4, :code 4,
		:date_5, :code 5, :date_6, :code 6
	),
	Number of Series( 2 ),
	Output Table( "Stacked" )
);
wait(0);
// Delete selected rows
Data Table( "Stacked" ) &amp;lt;&amp;lt; Select Where( Is Missing( :Data 2 ) ) &amp;lt;&amp;lt; Delete Rows;

// Delete columns
Data Table( "Stacked" ) &amp;lt;&amp;lt; Delete Columns( :Label, :Label 2 );
// New column: is between
Data Table( "Stacked" ) &amp;lt;&amp;lt; New Column( "is between",
	Numeric,
	"Continuous",
	Format( "Best", 12 )
);
// Change column formula: is between
Data Table( "Stacked" ):is between &amp;lt;&amp;lt; Set Formula(
	:Data &amp;gt;= :Start date &amp;amp; :Data &amp;lt;= :Stop date
);

// Delete selected rows
Data Table( "Stacked" ) &amp;lt;&amp;lt; Select Where( :is between == 0 ) &amp;lt;&amp;lt; delete rows;

// Delete column: is between
Data Table( "Stacked" ) &amp;lt;&amp;lt; Delete Columns( :is between );

// Delete columns
Data Table( "Stacked" ) &amp;lt;&amp;lt; Delete Columns( :Stop date, :Start date, :Data );

// Split data table
// → Data Table( "Split" )
Data Table( "Stacked" ) &amp;lt;&amp;lt; Split(
	Split By( :Data 2 ),
	Split( :Data 2 ),
	Group( :record_id ),
	Output Table( "Split" ),
	Sort by Column Property
);

// Combine columns
Data Table( "Split" ) &amp;lt;&amp;lt; Combine Columns(
	columns( :"1"n, :"2"n, :"3"n ),
	Column Name( "Result" ),
	Delimiter( "," )
);


// Delete columns
Data Table( "Split" ) &amp;lt;&amp;lt; Delete Columns( :"1"n, :"2"n, :"3"n );

// Update data table
Data Table( "example table" ) &amp;lt;&amp;lt; Update(
	With( Data Table( "Split" ) ),
	Match Columns( :record_id = :record_id )
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One can also open a new workflow, turn on the recorder and step through the steps and you will end up with a workflow that can be used in the future to create the solution.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1734293113511.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71250iB412F5ED97CC0C4D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1734293113511.png" alt="txnelson_0-1734293113511.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 20:05:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823039#M100280</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-12-15T20:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823525#M100293</link>
      <description>&lt;P&gt;Thanks so much for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 15:28:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823525#M100293</guid>
      <dc:creator>PruningTheSpark</dc:creator>
      <dc:date>2024-12-16T15:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a script to select only certain values related to specific date range</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823526#M100294</link>
      <description>&lt;P&gt;Thanks so much for the help!&amp;nbsp; The screenshots are very helpful!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 15:29:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-script-to-select-only-certain-values-related-to/m-p/823526#M100294</guid>
      <dc:creator>PruningTheSpark</dc:creator>
      <dc:date>2024-12-16T15:29:41Z</dc:date>
    </item>
  </channel>
</rss>

