<?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 How do I delete duplicate rows? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809798#M99112</link>
    <description>&lt;P&gt;The deletion of duplicate rows is starting to frustrate me! I'm on version 18.&lt;BR /&gt;&lt;BR /&gt;In the following script I have Sorted the table on SN (asc), Date &amp;amp; Time (desc). I then create a New Column "DuplicateFlag" and then apply the Formula&amp;nbsp;&lt;CODE class=" language-jsl"&gt;If( Lag(:SN, 1) == :SN, 1, 0 ).&amp;nbsp;This&amp;nbsp;adds&amp;nbsp;0&amp;nbsp;for&amp;nbsp;no&amp;nbsp;duplicate&amp;nbsp;and&amp;nbsp;1&amp;nbsp;for&amp;nbsp;duplicate.&amp;nbsp;We&amp;nbsp;then&amp;nbsp;Select&amp;nbsp;the&amp;nbsp;rows&amp;nbsp;=&amp;nbsp;to&amp;nbsp;1&amp;nbsp;and&amp;nbsp;Delete&amp;nbsp;the&amp;nbsp;Selected&amp;nbsp;Rows.&lt;BR /&gt;&lt;BR /&gt;This&amp;nbsp;appears&amp;nbsp;to&amp;nbsp;work&amp;nbsp;great&amp;nbsp;when&amp;nbsp;the&amp;nbsp;Date&amp;nbsp;and&amp;nbsp;Time&amp;nbsp;are&amp;nbsp;of&amp;nbsp;different&amp;nbsp;values&amp;nbsp;for&amp;nbsp;the&amp;nbsp;associated&amp;nbsp;SN.&amp;nbsp;However,&amp;nbsp;when&amp;nbsp;the&amp;nbsp;Date&amp;nbsp;&amp;amp;&amp;nbsp;Time&amp;nbsp;are&amp;nbsp;the&amp;nbsp;same&amp;nbsp;for&amp;nbsp;the&amp;nbsp;associated&amp;nbsp;SN&amp;nbsp;it&amp;nbsp;does&amp;nbsp;not&amp;nbsp;delete&amp;nbsp;the&amp;nbsp;duplicate&amp;nbsp;SN.&lt;BR /&gt;&lt;BR /&gt;What&amp;nbsp;suggestions&amp;nbsp;to&amp;nbsp;ensure&amp;nbsp;that&amp;nbsp;all&amp;nbsp;duplicate&amp;nbsp;SN's&amp;nbsp;are&amp;nbsp;successfully&amp;nbsp;deleted.&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Sort the SIDE_1_PRE_MTG table by SN (ascending), Date (descending), and Time (descending)
dt_sort = dt_erroneousdelete &amp;lt;&amp;lt; Sort(
    By( :SN, :Date, :Time ),
    Order( Ascending, Descending, Descending ),
    Replace Table
);

// Add a DuplicateFlag column to mark duplicate SN entries
dt_sort &amp;lt;&amp;lt; New Column("DuplicateFlag",
    Numeric,
    "Continuous",
    Formula(
        If( Lag(:SN, 1) == :SN, 1, 0 )
    )
);

// Select rows where DuplicateFlag is 1 and delete them
dt_sort &amp;lt;&amp;lt; Select Where( :DuplicateFlag == 1 );
dt_sort &amp;lt;&amp;lt; Delete Rows; // Deletes the selected rows

// Remove the DuplicateFlag column after deleting duplicates
dt_sort &amp;lt;&amp;lt; Delete Columns("DuplicateFlag");&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Nov 2024 14:53:21 GMT</pubDate>
    <dc:creator>DTDummy99</dc:creator>
    <dc:date>2024-11-06T14:53:21Z</dc:date>
    <item>
      <title>How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809798#M99112</link>
      <description>&lt;P&gt;The deletion of duplicate rows is starting to frustrate me! I'm on version 18.&lt;BR /&gt;&lt;BR /&gt;In the following script I have Sorted the table on SN (asc), Date &amp;amp; Time (desc). I then create a New Column "DuplicateFlag" and then apply the Formula&amp;nbsp;&lt;CODE class=" language-jsl"&gt;If( Lag(:SN, 1) == :SN, 1, 0 ).&amp;nbsp;This&amp;nbsp;adds&amp;nbsp;0&amp;nbsp;for&amp;nbsp;no&amp;nbsp;duplicate&amp;nbsp;and&amp;nbsp;1&amp;nbsp;for&amp;nbsp;duplicate.&amp;nbsp;We&amp;nbsp;then&amp;nbsp;Select&amp;nbsp;the&amp;nbsp;rows&amp;nbsp;=&amp;nbsp;to&amp;nbsp;1&amp;nbsp;and&amp;nbsp;Delete&amp;nbsp;the&amp;nbsp;Selected&amp;nbsp;Rows.&lt;BR /&gt;&lt;BR /&gt;This&amp;nbsp;appears&amp;nbsp;to&amp;nbsp;work&amp;nbsp;great&amp;nbsp;when&amp;nbsp;the&amp;nbsp;Date&amp;nbsp;and&amp;nbsp;Time&amp;nbsp;are&amp;nbsp;of&amp;nbsp;different&amp;nbsp;values&amp;nbsp;for&amp;nbsp;the&amp;nbsp;associated&amp;nbsp;SN.&amp;nbsp;However,&amp;nbsp;when&amp;nbsp;the&amp;nbsp;Date&amp;nbsp;&amp;amp;&amp;nbsp;Time&amp;nbsp;are&amp;nbsp;the&amp;nbsp;same&amp;nbsp;for&amp;nbsp;the&amp;nbsp;associated&amp;nbsp;SN&amp;nbsp;it&amp;nbsp;does&amp;nbsp;not&amp;nbsp;delete&amp;nbsp;the&amp;nbsp;duplicate&amp;nbsp;SN.&lt;BR /&gt;&lt;BR /&gt;What&amp;nbsp;suggestions&amp;nbsp;to&amp;nbsp;ensure&amp;nbsp;that&amp;nbsp;all&amp;nbsp;duplicate&amp;nbsp;SN's&amp;nbsp;are&amp;nbsp;successfully&amp;nbsp;deleted.&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Sort the SIDE_1_PRE_MTG table by SN (ascending), Date (descending), and Time (descending)
dt_sort = dt_erroneousdelete &amp;lt;&amp;lt; Sort(
    By( :SN, :Date, :Time ),
    Order( Ascending, Descending, Descending ),
    Replace Table
);

// Add a DuplicateFlag column to mark duplicate SN entries
dt_sort &amp;lt;&amp;lt; New Column("DuplicateFlag",
    Numeric,
    "Continuous",
    Formula(
        If( Lag(:SN, 1) == :SN, 1, 0 )
    )
);

// Select rows where DuplicateFlag is 1 and delete them
dt_sort &amp;lt;&amp;lt; Select Where( :DuplicateFlag == 1 );
dt_sort &amp;lt;&amp;lt; Delete Rows; // Deletes the selected rows

// Remove the DuplicateFlag column after deleting duplicates
dt_sort &amp;lt;&amp;lt; Delete Columns("DuplicateFlag");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 14:53:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809798#M99112</guid>
      <dc:creator>DTDummy99</dc:creator>
      <dc:date>2024-11-06T14:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809810#M99116</link>
      <description>&lt;P&gt;I'm not sure I'm following exactly what you're looking for. Would something like this work, but modified for your data table?&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; Select duplicate rows( Match( :age, :height ) );
dt &amp;lt;&amp;lt; Delete rows ();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 15:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809810#M99116</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2024-11-06T15:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809820#M99122</link>
      <description>&lt;P&gt;I did try the simplistic suggestion you offered but it didn't work either.&lt;BR /&gt;&lt;BR /&gt;The problem seems to when the 3 columns that I sort by.....&lt;BR /&gt;SN in Ascending order, Date in Descending order and Time in Descending order (this puts the most recent record by SN on top or first in-line), are all the same values. Per the attached screen shot you can see the SN, Date &amp;amp; Time are all the same values per associated SN (I color coded each matching set)..&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 16:42:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809820#M99122</guid>
      <dc:creator>DTDummy99</dc:creator>
      <dc:date>2024-11-06T16:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809826#M99125</link>
      <description>&lt;P&gt;If I understand correctly what you are trying to do, Select Duplicate Rows should work &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/select-rows.shtml#" target="_blank"&gt;https://www.jmp.com/support/help/en/18.0/#page/jmp/select-rows.shtml#&lt;/A&gt;. Can you provide a dataset (mockup is most likely fine) where you mark which rows you wish to delete.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 16:57:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809826#M99125</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-11-06T16:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809827#M99126</link>
      <description>&lt;P&gt;Are the Date and Time columns JMP numeric Date/Time columns?&amp;nbsp; If so, the displayed values for the Date column may display the same, but the actual numeric values(number of seconds since 01JAN1904) may be different.&amp;nbsp; Change the display format for the Date column to Fixed Dec, 20, 4 and see if there are differences.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 17:00:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809827#M99126</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-11-06T17:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809918#M99155</link>
      <description>&lt;P&gt;I figured out my problem, It was related to a Join from another table that unknown to me had duplicates. Once I cleaned up that table by removing the duplicates everything worked fine.&lt;BR /&gt;&lt;BR /&gt;I did use your code to delete the duplicates in the table that I Joined to, it worked perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 18:05:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809918#M99155</guid>
      <dc:creator>DTDummy99</dc:creator>
      <dc:date>2024-11-07T18:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete duplicate rows?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809919#M99156</link>
      <description>&lt;P&gt;Very interesting on the JMP numeric Date/Time columns. I'll need to watch out for that in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 18:07:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-delete-duplicate-rows/m-p/809919#M99156</guid>
      <dc:creator>DTDummy99</dc:creator>
      <dc:date>2024-11-07T18:07:30Z</dc:date>
    </item>
  </channel>
</rss>

