<?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 JMP - Column that generates unique row numbers by comparing between existing rows? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14339#M13403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have the following sample data&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 1&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 2&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 4&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 5&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 6&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 7&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 8&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 9&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 10&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 11&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a given row (aka unique ID and Date pair), how to create a new column to indicate this row is Date number X (of Y rows for each unique ID)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 1&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 2&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 3&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 4&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 5&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 6&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 7&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 8&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 9&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 10&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 11&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 12&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this small sample set, I can easily do manually. However, I do not know how to write a script using available JMP/jsl functions to compared between rows to do this for a large data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Sep 2015 23:08:34 GMT</pubDate>
    <dc:creator>optflow</dc:creator>
    <dc:date>2015-09-16T23:08:34Z</dc:date>
    <item>
      <title>JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14339#M13403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have the following sample data&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 1&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 2&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 4&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 5&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 6&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 7&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 8&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 9&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 10&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 11&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a given row (aka unique ID and Date pair), how to create a new column to indicate this row is Date number X (of Y rows for each unique ID)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 1&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 2&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 1&amp;nbsp; Date 3&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 4&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 5&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 6&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 2&amp;nbsp; Date 7&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 8&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 9&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 10&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 11&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;ID 3&amp;nbsp; Date 12&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this small sample set, I can easily do manually. However, I do not know how to write a script using available JMP/jsl functions to compared between rows to do this for a large data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2015 23:08:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14339#M13403</guid>
      <dc:creator>optflow</dc:creator>
      <dc:date>2015-09-16T23:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14340#M13404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are several ways to do this. For example, copy the code below and paste it into the formula property of a new column. It's supposed to return the number of all instances of an ID up to the current row (the ID column is assumed to be named "ID").&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Eval&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Eval Expr&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Col Sum&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Row&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;()&lt;/STRONG&gt; &lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: navy;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Expr&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: #0000dd;"&gt;Row&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 13.0pt; font-family: Courier;"&gt;())&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: navy;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: navy;"&gt;:&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.0pt; font-family: Courier; color: black;"&gt;ID&lt;STRONG&gt;)))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For very big data tables there are probably faster approaches.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2015 00:26:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14340#M13404</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2015-09-17T00:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14341#M13405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also use one of these formulas, &lt;STRONG&gt;after using sort by (ID, Date).&lt;/STRONG&gt; One formulas counts the number of times there is a date (any date) for a given ID, the second one counts the number of times there is a &lt;STRONG&gt;new&lt;/STRONG&gt; date for a given ID (see rows 12 to 14 in screenshot).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(Row() == 1, 1, If(:ID[Row() - 1,Empty()] == :ID, :Date# for that ID[Row() - 1,Empty()] + 1, If(:ID[Row() - 1,Empty()] != :ID, 1, Empty())))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(Row() == 1, 1, If(:ID[Row() - 1,Empty()] == :ID, If(:Date[Row() - 1,Empty()] != :Date, :Unique Date# for that ID[Row() - 1,Empty()] + 1, :Unique Date# for that ID[Row() - 1,Empty()]), If(:ID[Row() - 1,Empty()] != :ID, 1, Empty())))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9883_JMP forum.png" style="width: 1243px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2187iA1C9A600B4AB0ED9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9883_JMP forum.png" alt="9883_JMP forum.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 00:39:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14341#M13405</guid>
      <dc:creator>jvillaumie</dc:creator>
      <dc:date>2016-10-19T00:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14342#M13406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 20:53:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14342#M13406</guid>
      <dc:creator>optflow</dc:creator>
      <dc:date>2015-09-18T20:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14343#M13407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 20:54:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14343#M13407</guid>
      <dc:creator>optflow</dc:creator>
      <dc:date>2015-09-18T20:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: JMP - Column that generates unique row numbers by comparing between existing rows?</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14344#M13408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For large datasets you might try the following; assuming the first column is sorted as in your example, the expression below will work as a formula in a new column. It takes my machine about 2 seconds on a 1M row dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;SPAN style="color: #032ce4;"&gt;Row&lt;/SPAN&gt;() &lt;SPAN style="color: #011993;"&gt;-&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Col Min&lt;/SPAN&gt;( &lt;SPAN style="color: #032ce4;"&gt;Row&lt;/SPAN&gt;()&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;:&lt;/SPAN&gt;ID )) &lt;SPAN style="color: #011993;"&gt;+&lt;/SPAN&gt; &lt;SPAN style="color: #009193; font-size: 10pt; line-height: 1.5em;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Brady&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 21:16:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Column-that-generates-unique-row-numbers-by-comparing/m-p/14344#M13408</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2015-09-18T21:16:24Z</dc:date>
    </item>
  </channel>
</rss>

