<?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: How do I create a new data table combining duplicate rows? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747996#M92798</link>
    <description>&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>Thu, 18 Apr 2024 17:07:30 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2024-04-18T17:07:30Z</dc:date>
    <item>
      <title>How do I create a new data table combining duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747977#M92796</link>
      <description>&lt;P&gt;I have a indexed list of production runs of different products (A-H) and their start and end times. Sometimes there are two lines in a row with the same product (rows 1 &amp;amp; 2 and 7 &amp;amp; 8)&lt;/img&gt; and I would like those to be combined into one row with the start time of the first row and end time of the second row. How would I use JSL to do this?&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="gmc5149_0-1713457204801.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/63471iCFEB2D5EEEDAE55C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gmc5149_0-1713457204801.png" alt="gmc5149_0-1713457204801.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 16:22:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747977#M92796</guid>
      <dc:creator>gmc5149</dc:creator>
      <dc:date>2024-04-18T16:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new data table combining duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747990#M92797</link>
      <description>&lt;P&gt;I think this should do what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add new (numeric) column to your table to calculate "groups" with formula like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1,
	counter = 0;
);
If(:Product != Lag(:Product),
	counter++;
);
counter;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use Summary table to perform the min/max part&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1713458056939.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/63473i931158173607E606/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_1-1713458056939.png" alt="jthi_1-1713458056939.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Remove and re-order columns from summary table as needed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a script from Enhanced Log to perform those actions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Open Data Table: Run Time Index.jmp
// → Data Table("Run Time Index")
Open("$DOWNLOADS/Run Time Index.jmp");

// New column: R
Data Table("Run Time Index") &amp;lt;&amp;lt; New Column("R",
	Numeric,
	"Continuous",
	Format("Best", 12),
	Formula(
		If(Row() == 1, counter = 0);
		If(:Product != Lag(:Product),
			counter
			++);
		counter;
	)
);

// Data table summary
// → Data Table("Run Time Index By (R, Product)")
Data Table("Run Time Index") &amp;lt;&amp;lt; Summary(
	Group(:R, :Product),
	Min(:Run Index),
	Min(:Start),
	Max(:End),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0)
);

// Delete columns
Data Table("Run Time Index By (R, Product)") &amp;lt;&amp;lt; Delete Columns(:R, :N Rows);

// Move selected column: Run Index
Data Table("Run Time Index By (R, Product)") &amp;lt;&amp;lt; Move Selected Columns({:Run Index}, To First);

// Change column modeling type: Run Index
Data Table("Run Time Index By (R, Product)"):Run Index &amp;lt;&amp;lt; Set Modeling Type("Ordinal");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 16:39:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747990#M92797</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-18T16:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new data table combining duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747996#M92798</link>
      <description>&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>Thu, 18 Apr 2024 17:07:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747996#M92798</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-04-18T17:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a new data table combining duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747997#M92799</link>
      <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 17:17:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-new-data-table-combining-duplicate-rows/m-p/747997#M92799</guid>
      <dc:creator>gmc5149</dc:creator>
      <dc:date>2024-04-18T17:17:27Z</dc:date>
    </item>
  </channel>
</rss>

