<?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: create new id to deal with multiple to multiple relationship in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365931#M61545</link>
    <description>&lt;P&gt;Thank you so much Jarmo! This outcome out of your script is exactly what i need. I'm not familiar with script so just one following question on how to apply it on my current table. the two column names are "Individualid" and "Email_HASHED", I pasted the below edited script to my table but it showed error. could you debug for me? Thank you!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column("newid", numeric, ordinal);

createIndex = function({tempRows, index},
wait(0.5); //for visualization
idList = Individualid[tempRows,0];
emailList = Email_HASHED[tempRows,0];
tempRowsNew = Get Rows Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED));
Select Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED)); //for visualization
wait(0.5); //for visualization
If(N Items(tempRows) != N Items(tempRowsNew),
ids = Individualid[tempRowsNew,0];
emails = Email_HASHED[tempRowsNew,0];
Recurse(tempRowsNew, index),
If(All(tempRows == tempRowsNew),
newId[tempRowsNew] = index;
newRow = Contains(newId &amp;lt;&amp;lt; get as matrix, .);
If(newRow == 0,
Clear Select;
return("done"),
ids = Individualid[newRow,0];
emails = Email_HASHED[newRow,0];
Recurse(matrix(newRow), index + 1);
);

)
);
);

wait(1);
createIndex([1], 1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 04:37:57 GMT</pubDate>
    <dc:creator>joann</dc:creator>
    <dc:date>2021-03-08T04:37:57Z</dc:date>
    <item>
      <title>create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365298#M61470</link>
      <description>&lt;P class="p1"&gt;*Update&lt;/P&gt;&lt;P class="p1"&gt;Sorry I should be more clear on the question. The data i currently have looks like:&lt;/P&gt;&lt;P class="p1"&gt;id&amp;nbsp; &amp;nbsp; email&lt;/P&gt;&lt;P class="p1"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;a&lt;/P&gt;&lt;P class="p1"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P class="p1"&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;a&lt;/P&gt;&lt;P class="p1"&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;c&lt;/P&gt;&lt;P class="p1"&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/P&gt;&lt;P class="p1"&gt;We can see that id 1 2 and email a b c are actually the same person because the info overlaps.&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;What I'm trying to do here is to come up with a match table with a new key which i can use to match back to the original table to identify those overlap ones are actually the same person:&lt;/P&gt;&lt;P class="p1"&gt;newID&amp;nbsp; &amp;nbsp;id/email&lt;/P&gt;&lt;P class="p1"&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P class="p1"&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P class="p1"&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a&lt;/P&gt;&lt;P class="p1"&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/P&gt;&lt;P class="p1"&gt;111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c&lt;/P&gt;&lt;P class="p1"&gt;222&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/P&gt;&lt;P class="p1"&gt;The newID doesn't need to be in a specific form, it can even equal to the original id, as long as we can use it to identify a "unique person".&lt;/P&gt;&lt;P class="p1"&gt;-------------------------------------&lt;/P&gt;&lt;P class="p1"&gt;Hi, I have data with 2 columns, one is individual id, and one is email. The problem with this data is that the relationship between individual id and email is multiple to multiple, meaning one individual id could has multiple emails, and one email could have multiple individual ids. Thus i’d need to create a mapping table of a new unique id to all individualID/email, which specifies that those individual ids or emails if any overlap are actually the same person. I couldn’t really think of a way to do it without script. Could anyone help? Thank you!&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 00:29:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365298#M61470</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2023-06-09T00:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365373#M61479</link>
      <description>&lt;P&gt;So where would you get the info that tells you what unique number is a unique person? Based on only these two columns you are describing you have no other choice than to make one of the column the unique identifier and map the other one on to it. Maybe post some example data?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 09:02:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365373#M61479</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2021-03-05T09:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365414#M61486</link>
      <description>&lt;P&gt;I don't think I understand what you want.&amp;nbsp; It sounds like you could just concatenate the two columns and you would have a unique person/email combination for each observation.&amp;nbsp; If you want each person or each email in its own row, just use Tabulate.&amp;nbsp; I've attached a sample table showing the multiple-multiple mapping, with a Tabulation as well as a new column with a unique identifier.&amp;nbsp; Perhaps you can use this example to tell us what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 12:05:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365414#M61486</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2021-03-05T12:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365427#M61489</link>
      <description>&lt;P&gt;I think what is needed is a table like:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Person&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;email&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;10,15&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:10@company.com," target="_blank" rel="noopener"&gt;a@company.com,&lt;/A&gt;&amp;nbsp;e@company.com&lt;A href="mailto:10@company.com," target="_blank" rel="noopener"&gt;,&lt;/A&gt;&amp;nbsp;g@company.com&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:b@company.com," target="_blank" rel="noopener"&gt;b@company.com,&lt;/A&gt;&amp;nbsp;e@company.com&lt;A href="mailto:10@company.com," target="_blank" rel="noopener"&gt;,&lt;/A&gt;&amp;nbsp;g@company.com&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;12,16,18&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:10@company.com," target="_blank" rel="noopener"&gt;c@company.com,&lt;/A&gt;&amp;nbsp;f&lt;A href="mailto:10@company.com," target="_blank" rel="noopener"&gt;@company.com,&lt;/A&gt;&amp;nbsp;g@company.com&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from a table that looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;email&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is unclear to me how you would know which ID's and which email's belong to the same person so that is what my question was about.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 13:40:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365427#M61489</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2021-03-05T13:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365429#M61490</link>
      <description>&lt;P&gt;I think you can do that by tabulating (as in my example), then making into a data table and then creating a column concatenating (multiple concatenates if you want to insert the ", ").&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 13:55:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365429#M61490</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2021-03-05T13:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365495#M61499</link>
      <description>Hi Paul! I updated the info in the original post. Please check it, thank you!</description>
      <pubDate>Fri, 05 Mar 2021 16:10:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365495#M61499</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-05T16:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365496#M61500</link>
      <description>Hi Dale! I updated the info in the original post. Please check it, thank you!</description>
      <pubDate>Fri, 05 Mar 2021 16:11:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365496#M61500</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-05T16:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365701#M61513</link>
      <description>&lt;P&gt;I think you need someone to script this.&amp;nbsp; I've tried a number of ways but can't seem to get anything that works - and so many steps were involved that it doesn't seem worth it.&amp;nbsp; I do find the situation a bit strange however - you have people with multiple email addresses, as is common, but you also have multiple people using the same email address, which also happens.&amp;nbsp; However, you want to identify unique people - I don't see why you would say that two people sharing the same email address are really only one person?&amp;nbsp; In your example, you appear to want to exclude person id #2 as a unique person because they share email addresses with others.&amp;nbsp; But why would that mean they are not a unique person?&amp;nbsp; Is it possible that you are complicating this problem more than necessary?&amp;nbsp; My inclination would be to just focus on unique ids and then want the list of email addresses that are associated with them, a simple tabulate function.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 12:12:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365701#M61513</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2021-03-06T12:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365702#M61514</link>
      <description>&lt;P&gt;This definitely seems a bit weird way to with this as &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1701"&gt;@dale_lehman&lt;/a&gt; said. You could script this at least with recursion. Below is very messy example code which seemed to work at least with my example data (if I understood the idea correctly):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(20),
	Compress File When Saved(1),
	New Column("id",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 7, 8, 9])
	),
	New Column("email",
		Character,
		"Nominal",
		Set Values(
			{"a", "b", "a", "c", "d", "e", "f", "g", "a", "h", "i", "j", "k", "l",
			"m", "n", "o", "p", "q", "b"}
		)
	)
);

dt &amp;lt;&amp;lt; Size Window(500,900);
dt &amp;lt;&amp;lt; New Column("newid", numeric, ordinal);

createIndex = function({tempRows, index},
	wait(0.5); //for visualization
	idList = dt:id[tempRows,0];
	emailList = dt:email[tempRows,0];
	tempRowsNew = dt &amp;lt;&amp;lt; Get Rows Where(Contains(idList, :id) | Contains(emailList, :email));
	dt &amp;lt;&amp;lt; Select Where(Contains(idList, :id) | Contains(emailList, :email)); //for visualization
	wait(0.5); //for visualization
	If(N Items(tempRows) != N Items(tempRowsNew),
		ids = dt:id[tempRowsNew,0];
		emails = dt:email[tempRowsNew,0];
		Recurse(tempRowsNew, index),
		If(All(tempRows == tempRowsNew),
			dt:newId[tempRowsNew] = index;
			newRow = Contains(dt:newId &amp;lt;&amp;lt; get as matrix, .);
			If(newRow == 0,
				dt &amp;lt;&amp;lt; Clear Select;
				return("done"),
				ids = dt:id[newRow,0];
				emails = dt:email[newRow,0];
				Recurse(matrix(newRow), index + 1);
			);

		)
	);
);

wait(1);
createIndex([1], 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I added extra Select Where and Waits inside the function to try to show what is going on.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 13:57:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365702#M61514</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-06T13:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365922#M61544</link>
      <description>Thank you Dale! Yes it's a valid point but for this business case we decided to treat people with the same email as one person in order to calculate the sequence of their other behavior.</description>
      <pubDate>Sun, 07 Mar 2021 21:52:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365922#M61544</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-07T21:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365931#M61545</link>
      <description>&lt;P&gt;Thank you so much Jarmo! This outcome out of your script is exactly what i need. I'm not familiar with script so just one following question on how to apply it on my current table. the two column names are "Individualid" and "Email_HASHED", I pasted the below edited script to my table but it showed error. could you debug for me? Thank you!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column("newid", numeric, ordinal);

createIndex = function({tempRows, index},
wait(0.5); //for visualization
idList = Individualid[tempRows,0];
emailList = Email_HASHED[tempRows,0];
tempRowsNew = Get Rows Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED));
Select Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED)); //for visualization
wait(0.5); //for visualization
If(N Items(tempRows) != N Items(tempRowsNew),
ids = Individualid[tempRowsNew,0];
emails = Email_HASHED[tempRowsNew,0];
Recurse(tempRowsNew, index),
If(All(tempRows == tempRowsNew),
newId[tempRowsNew] = index;
newRow = Contains(newId &amp;lt;&amp;lt; get as matrix, .);
If(newRow == 0,
Clear Select;
return("done"),
ids = Individualid[newRow,0];
emails = Email_HASHED[newRow,0];
Recurse(matrix(newRow), index + 1);
);

)
);
);

wait(1);
createIndex([1], 1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 04:37:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365931#M61545</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-08T04:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365973#M61550</link>
      <description>&lt;P&gt;I modified the script a little (changed recursion to while loop as recursion might be a bit difficult from time to time to understand). Also changed column names.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
//https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365298#M61470
dt = New Table("Untitled",
	Add Rows(20),
	Compress File When Saved(1),
	New Column("Individualid",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 7, 8, 9])
	),
	New Column("Email_HASHED",
		Character,
		"Nominal",
		Set Values(
			{"a", "b", "a", "c", "d", "e", "f", "g", "a", "h", "i", "j", "k", "l",
			"m", "n", "o", "p", "q", "b"}
		)
	)
);

dt &amp;lt;&amp;lt; Size Window(500,900);
dt &amp;lt;&amp;lt; New Column("newid", numeric, ordinal);

//setup first values before While loop
rowList = [1];
idList = dt:Individualid[rowList,0];
emailList = dt:Email_HASHED[rowList,0];
index = 1;
//looping
While(1,
	oldRowList = rowList;
	rowList = dt &amp;lt;&amp;lt; Get Rows Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED));
	dt &amp;lt;&amp;lt; Select Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED)); //for visualization
	wait(1); //for visualization
	If(N Items(oldRowList) != N Items(rowList),
		idList = dt:Individualid[rowList,0];
		emailList = dt:Email_HASHED[rowList,0],
		If(All(oldRowList == rowList),
			dt:newid[rowList] = index;
			newRow = Contains(dt:newid &amp;lt;&amp;lt; get as matrix, .);
			If(newRow == 0,
				break(),
			);
			index += 1;
			rowList = Matrix(newRow);
			idList = dt:Individualid[rowList,0];
			emailList = dt:Email_HASHED[rowList,0];
		);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You seen to have removed the dt references from your modified version, that could cause issues.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 05:34:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365973#M61550</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-08T05:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366124#M61578</link>
      <description>Thank you Jarmo! How do I change the dt to my current data table but not creating the new table with the samples you put in?</description>
      <pubDate>Mon, 08 Mar 2021 15:33:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366124#M61578</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-08T15:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366133#M61581</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data table("Name of table here")&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 15:53:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366133#M61581</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2021-03-08T15:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366155#M61583</link>
      <description>&lt;P&gt;And depending how you get the datatable you can reference it directly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt1 = dt &amp;lt;&amp;lt; Subset(All rows);
dt2 = Query(dt, "SELECT name, age, height FROM 'Big Class' WHERE age &amp;gt; 14; ");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:18:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366155#M61583</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-08T16:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366263#M61599</link>
      <description>Thank you so much Jarmo! It works!! Really appreciate your help.</description>
      <pubDate>Mon, 08 Mar 2021 22:39:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366263#M61599</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-08T22:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366268#M61600</link>
      <description>Hi Jarmo, I forgot to mention that in the email column there are some rows having empty cells, meaning some individualID does not have anything populated under email column. I found that the current script will consider all individual ids having no emails as the same new id. could you help adjust the script to avoid this kind of situation? Thank you!</description>
      <pubDate>Mon, 08 Mar 2021 23:04:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366268#M61600</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-08T23:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366293#M61605</link>
      <description>&lt;P&gt;How should they be handled? Most likely it is one or two if statements.&lt;/P&gt;&lt;P&gt;Small example dataset with correct answers could help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 05:54:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366293#M61605</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-09T05:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366436#M61619</link>
      <description>&lt;P&gt;Hi Jarmo, below is an example. you can see many rows having empty email are all grouped as newid 5. If the individualID is not overlapped with other groups, those without emails should each have their own newid. Thank you!&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="Screen Shot 2021-03-09 at 10.36.39 AM.png" style="width: 324px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31115iF01E0880835BDFF0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-03-09 at 10.36.39 AM.png" alt="Screen Shot 2021-03-09 at 10.36.39 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 15:40:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366436#M61619</guid>
      <dc:creator>joann</dc:creator>
      <dc:date>2021-03-09T15:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: create new id to deal with multiple to multiple relationship</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366510#M61624</link>
      <description>&lt;P&gt;Couldn't replicate your results (most likely you have different individual ids on the one starting with 308....)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the result from this look correct?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
//https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/365298#M61470

/*
dt = New Table("Untitled",
	Add Rows(20),
	Compress File When Saved(1),
	New Column("Individualid",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 7, 8, 9])
	),
	New Column("Email_HASHED",
		Character,
		"Nominal",
		Set Values(
			{"a", "b", "a", "c", "d", "e", "f", "g", "a", "h", "i", "j", "k", "l",
			"m", "n", "o", "p", "q", "b"}
		)
	)
);
*/

dt = New Table("Untitled",
	Add Rows(19),
	Compress File When Saved(1),
	New Column("Individualid",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values(
			[139, 100, 229, 301, 308, 284, 682, 136, 586, 256, 122, 711, 629, 116,
			152, 443, 301, 695, 311]
		)
	),
	New Column("Email_HASHED",
		Character,
		"Nominal",
		Set Values(
			{"A648", "CAA", "E7B", "5B2", "", "237A", "", "FE0", "", "7C21", "",
			"920B", "", "D394", "", "2FE1", "", "", ""}
		)
	)
);

dt &amp;lt;&amp;lt; Size Window(500,900);
dt &amp;lt;&amp;lt; New Column("newid", numeric, ordinal);

//setup first values before While loop
rowList = [1];
idList = dt:Individualid[rowList,0];
emailList = dt:Email_HASHED[rowList,0];
index = 1;
//looping
While(1,
	oldRowList = rowList;
	Remove From(emailList, Contains(emailList, ""));
	rowList = dt &amp;lt;&amp;lt; Get Rows Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED));
	//dt &amp;lt;&amp;lt; Select Where(Contains(idList, :Individualid) | Contains(emailList, :Email_HASHED)); //for visualization
	//wait(1); //for visualization
	If(N Items(oldRowList) != N Items(rowList),
		idList = dt:Individualid[rowList,0];
		emailList = dt:Email_HASHED[rowList,0],
		If(All(oldRowList == rowList),
			dt:newid[rowList] = index;
			newRow = Contains(dt:newid &amp;lt;&amp;lt; get as matrix, .);
			
			newRow = 0;
			For Each Row(dt,
				If(:Email_HASHED != "" &amp;amp; IsMissing(:newId),
					newRow = Row();
					break();
				)
			);
			
			If(newRow == 0,
				break(),
			);
			index += 1;
			rowList = Matrix(newRow);
			idList = dt:Individualid[rowList,0];
			emailList = dt:Email_HASHED[rowList,0];
		);
	);
);
//dt &amp;lt;&amp;lt; Clear Select;
//handle missings
index++;
missingRows = dt &amp;lt;&amp;lt; Get Rows Where(IsMissing(:newId));
dt:newId[missingRows] = index&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 17:34:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-id-to-deal-with-multiple-to-multiple-relationship/m-p/366510#M61624</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-09T17:34:58Z</dc:date>
    </item>
  </channel>
</rss>

