<?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 data table from min-max dates and making a spine of data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/299843#M55920</link>
    <description>It is pretty tough to provide any coding assistants without seeing your imported Excel file(s).  Would you please provide a sample of your input file that has the table variables, etc.?</description>
    <pubDate>Fri, 04 Sep 2020 15:00:53 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-09-04T15:00:53Z</dc:date>
    <item>
      <title>creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/299058#M55894</link>
      <description>&lt;P&gt;I'm back from an 7 year hiatus from JMP scripting and I'm looking for some help to create a data table based on min and max dates and a list of things. I'm already importing the list of things from an excel file and it's in a data table, but what I need to do is take my min/max dates and combine them with my list of things by iterating on a 1 month interval from the min date to the max date (inclusive). I already have the min/max dates stored as table variables in m/y format.&amp;nbsp; Structurally, I'd like the data table to have two columns, Date, and ThingsList with the ThingsList repeated for each date. See below for an example of how I'd like the data to be structured.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mindate is "month1" in the example below with maxdate being "month3".&amp;nbsp; How can this be scripted? Appreciate the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thing1 Month1&lt;/P&gt;&lt;P&gt;thing2 Month1&lt;/P&gt;&lt;P&gt;thing3 Month1&lt;/P&gt;&lt;P&gt;thing1 Month2&lt;/P&gt;&lt;P&gt;thing2 Month2&lt;/P&gt;&lt;P&gt;thing3 Month2&lt;/P&gt;&lt;P&gt;thing1 Month3&lt;/P&gt;&lt;P&gt;thing2 Month3&lt;/P&gt;&lt;P&gt;thing3 Month3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what i have so far, basically to define the min/max date and populate the data table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Window( "Set Date Range for Data Merge",
	&amp;lt;&amp;lt;Modal, 
	sd = Date Increment( Today(), "year", -2, "start" );
	ed = Today();
	H List Box(
		Text Box( "From:" ),
		scal = Number Edit Box( sd, &amp;lt;&amp;lt;Set Format( Format( "m/y" ) ), &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( "m/y" ) ), &amp;lt;&amp;lt;SetFunction( Function( {this}, ed = ecal &amp;lt;&amp;lt; Get ) ), &amp;lt;&amp;lt;Set Show Spin Box(1) ),
	);
);

startdate = Format Date( sd, "m/y" );
enddate = Format Date( ed, "m/y" );

Show( startdate, enddate );

merge = New Table( "Merge" );
merge &amp;lt;&amp;lt; New Column( "Month" );
merge &amp;lt;&amp;lt; New Column ( "Things");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:18:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/299058#M55894</guid>
      <dc:creator>JM13</dc:creator>
      <dc:date>2023-06-10T23:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/299843#M55920</link>
      <description>It is pretty tough to provide any coding assistants without seeing your imported Excel file(s).  Would you please provide a sample of your input file that has the table variables, etc.?</description>
      <pubDate>Fri, 04 Sep 2020 15:00:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/299843#M55920</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-04T15:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/303710#M56046</link>
      <description>&lt;P&gt;Attached are basic examples of what my input table would look like and what i'd like to try to script to happen.&amp;nbsp; In the example I'm showing in "desired output.jmp" it has a startdate and enddate of 7/2020 and 11/2020 respectively that would be determined via the JSL in my previous post. Since my first post I've sort of figured out how to at least create a data table of dates using this JSL. The only problem is that the interval of one month (in seconds) doesn't quite work since all months are not the same length.&amp;nbsp; There has to be a more elegant way to do this.&amp;nbsp; Anyway, any help on how to take the input table and use the date range script arrive at the "desired output.jmp" would be greatly appreciated. I'm kind of lost.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test = New Table( "test" );
test &amp;lt;&amp;lt; New Column("test", Numeric, Continuous, Set Values(sd::ed::2628000));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 17:47:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/303710#M56046</guid>
      <dc:creator>JM13</dc:creator>
      <dc:date>2020-09-09T17:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/303835#M56060</link>
      <description>&lt;P&gt;Here is a script that takes the start and stop date and produces records for each month for each value of the things from the data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Set Date Range for Data Merge",
	&amp;lt;&amp;lt;Modal,
	sd = Date Increment( Today(), "year", -2, "start" );
	ed = Today();
	H List Box(
		Text Box( "From:" ),
		scal = Number Edit Box(
			sd,
			&amp;lt;&amp;lt;Set Format( Format( "m/y" ) ),
			&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( "m/y" ) ),
			&amp;lt;&amp;lt;SetFunction( Function( {this}, ed = ecal &amp;lt;&amp;lt; Get ) ),
			&amp;lt;&amp;lt;Set Show Spin Box( 1 )
		),

	);
);

dt = Current Data Table(); // Point to the table with the list of Things
things = dt:Thing &amp;lt;&amp;lt; get values;

numbMonths = Date Difference( sd, ed, "month" );

dtNew = New Table( "Output",
	New Column( "Thing" ),
	New Column( "Month-Year", Format( "m/y", 7 ) ),
	add rows( N Items( things ) * numbMonths )
);

theDay = Day( sd );
theMonth = Month( sd );
theYear = Year( sd );
theRow = 0;

For( monthCNT = 1, monthCNT &amp;lt;= numbMonths, monthCNT++,
	For( thingCNT = 1, thingCNT &amp;lt;= N Items( things ), thingCNT++,
		theRow++;
		:Thing[theRow] = things[thingCNT];
		:Name( "Month-Year" )[theRow] = Date MDY( theMonth, theDay, theYear );
	);
	If( theMonth &amp;lt; 12,
		theMonth = theMonth + 1,
		theMonth = 1;
		theYear = theYear + 1;
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Sep 2020 02:08:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/303835#M56060</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-10T02:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/306900#M56198</link>
      <description>&lt;P&gt;Thanks so much Jim! I'll give this a try and report back.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 17:44:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/306900#M56198</guid>
      <dc:creator>JM13</dc:creator>
      <dc:date>2020-09-14T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: creating data table from min-max dates and making a spine of data</title>
      <link>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/307996#M56238</link>
      <description>&lt;P&gt;Thanks! This worked great and i was able to adapt it perfectly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 21:37:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/creating-data-table-from-min-max-dates-and-making-a-spine-of/m-p/307996#M56238</guid>
      <dc:creator>JM13</dc:creator>
      <dc:date>2020-09-15T21:37:54Z</dc:date>
    </item>
  </channel>
</rss>

