<?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: Dealing with wildcards for joining tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224270#M44569</link>
    <description>&lt;P&gt;You can convert your KEY format to regular expression format.&lt;/P&gt;&lt;P&gt;dt1 is Table1 and dt2 is Table2.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1&amp;lt;&amp;lt;new column("KEY_reg",character,formula(substitute(:KEY,"|","","?","[A-Z0-9]")));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to use the &lt;STRONG&gt;update&lt;/STRONG&gt; command but not succesful.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt2&amp;lt;&amp;lt; update(with(dt1),match columns(regex(:KEY,:KEY_reg )))&amp;nbsp;//[NOT WORKING]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here are manual way to do the job.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1&amp;lt;&amp;lt;new column("KEY_reg",character,formula(substitute(:KEY,"|","","?","[A-Z0-9]")));
dt2&amp;lt;&amp;lt;new column("DATA");
for(r=1,r&amp;lt;=ncol(dt1),r++,
	r1 = dt2&amp;lt;&amp;lt;get rows where(not(is missing(regex(:KEY, dt1[r,"KEY_reg"]))));
	dt2[r1,"DATA"]=dt1[r,"DATA"];
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2019 20:34:59 GMT</pubDate>
    <dc:creator>jara95</dc:creator>
    <dc:date>2019-08-30T20:34:59Z</dc:date>
    <item>
      <title>Dealing with wildcards for joining tables</title>
      <link>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224248#M44568</link>
      <description>&lt;P&gt;I need to join multiple tables, but the column I need to join on has wildcards for one of the tables columns. The tables are not overly large so it doens't need to be very efficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Table1 KEY column below there could be any single alphanmueric character where the question marks are. In the Brackets are OR statements, so it could be 1 or 2 or 3 or 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example it should join onto rows 1&amp;amp;2 of Table2 since the wildcards would match. But row 3 has a 9 where the OR pattern only has 1|2|3|4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of duplicating the row for each possible alphanumeric combination where the question marks are, and for each combination in the OR brackets then the join would work - not sure how to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;KEY&lt;/TD&gt;&lt;TD&gt;DATA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC?Y?[1|2|3|4]Z&lt;/TD&gt;&lt;TD&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;KEY&lt;/TD&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1YA1Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 10:10:10 PM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCZYB4Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 11:11:11 PM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1YA9Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 12:12:12 PM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result Table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;KEY&lt;/TD&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;TD&gt;DATA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1YA1Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 10:10:10 PM&lt;/TD&gt;&lt;TD&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCZYB4Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 11:11:11 PM&lt;/TD&gt;&lt;TD&gt;99999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1YA9Z&lt;/TD&gt;&lt;TD&gt;2019/08/14 12:12:12PM&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;</description>
      <pubDate>Fri, 30 Aug 2019 18:02:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224248#M44568</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2019-08-30T18:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with wildcards for joining tables</title>
      <link>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224270#M44569</link>
      <description>&lt;P&gt;You can convert your KEY format to regular expression format.&lt;/P&gt;&lt;P&gt;dt1 is Table1 and dt2 is Table2.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1&amp;lt;&amp;lt;new column("KEY_reg",character,formula(substitute(:KEY,"|","","?","[A-Z0-9]")));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to use the &lt;STRONG&gt;update&lt;/STRONG&gt; command but not succesful.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt2&amp;lt;&amp;lt; update(with(dt1),match columns(regex(:KEY,:KEY_reg )))&amp;nbsp;//[NOT WORKING]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here are manual way to do the job.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1&amp;lt;&amp;lt;new column("KEY_reg",character,formula(substitute(:KEY,"|","","?","[A-Z0-9]")));
dt2&amp;lt;&amp;lt;new column("DATA");
for(r=1,r&amp;lt;=ncol(dt1),r++,
	r1 = dt2&amp;lt;&amp;lt;get rows where(not(is missing(regex(:KEY, dt1[r,"KEY_reg"]))));
	dt2[r1,"DATA"]=dt1[r,"DATA"];
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 20:34:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224270#M44569</guid>
      <dc:creator>jara95</dc:creator>
      <dc:date>2019-08-30T20:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with wildcards for joining tables</title>
      <link>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224291#M44576</link>
      <description>&lt;P&gt;Thank you Jara95 - this is very close to the solution. I made some small edits - not sure about how you were referencing column rows using this method:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1[r,"DATA"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I switched to this method and it works:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1:DATA[r]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also found that with Regex you can leave the OR&amp;nbsp;&lt;FONT size="5"&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;|&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;operators in place, no need to Substitute them out.&lt;/P&gt;&lt;P&gt;One final thing I changed is For loop from N Col to N Row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my final script looks something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1 &amp;lt;&amp;lt; New Column( "KEY_reg", character, formula( Substitute( dt1:KEY, "?", "[A-Z0-9]" ) ) );
dt2 &amp;lt;&amp;lt; New Column( "DATA" );
For( r = 1, r &amp;lt;= N Row( dt1 ), r++,
	r1 = dt2 &amp;lt;&amp;lt; Get Rows Where( !Is Missing( Regex( dt2:KEY, dt1:KEY_reg[r] ) ) );
	dt2:DATA[r1] = dt1:DATA[r];
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Sat, 31 Aug 2019 09:30:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dealing-with-wildcards-for-joining-tables/m-p/224291#M44576</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2019-08-31T09:30:59Z</dc:date>
    </item>
  </channel>
</rss>

