<?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: Join two tables with variable names in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53957#M30485</link>
    <description>&lt;P&gt;The problem is almost certainly with the square brackets in Name4.&amp;nbsp; If column names have special characters, then you cannot use the colon(:) with the column name.&amp;nbsp; You need to get the column name string wrapped in :Name().&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = ":Name(" || xvar || ")";
name2 = ":Name(" || yvar || ")";
name3 = name1 || " = " || name2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Mar 2018 19:30:02 GMT</pubDate>
    <dc:creator>cwillden</dc:creator>
    <dc:date>2018-03-27T19:30:02Z</dc:date>
    <item>
      <title>Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53949#M30479</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to join two tables with variable names. Here is the script.&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(
	Parse(
		"s3 &amp;lt;&amp;lt; Join(
With( rds),
Merge Same Name Columns,
By Matching Columns(
" || name3 || ",
" || name4 ||
		"
),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )
);"
&amp;nbsp;
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;I get an error " Name Unresolved: Red LED Hue x 64{1} in access or evaluation of "Red LED Hue 64/*###*/. No issue with name3 "Serail#" but issue with "Red LED Hue x 64[1]".&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;Here is the scrip that works fine but I like to replace the variables names with name3 and name4.&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "S3" ) &amp;lt;&amp;lt; Join(
	With( Data Table( "RDS" ) ),
	Merge Same Name Columns,
	By Matching Columns( :Serial# = :Serial#, :Name( "Red LED Hue x 64[1]" ) = :Name( "Red LED Hue x 64[1]" ) ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 1, 1 ),
	Preserve main table order( 1 )
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p3"&gt;&lt;SPAN style="font-family: inherit;"&gt;I appreciate your help.&amp;nbsp; Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 23:19:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53949#M30479</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-03-27T23:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53952#M30481</link>
      <description>&lt;P&gt;how are you defining name3 and name4?&amp;nbsp; Can you post that part of your script as well as show how those variables evaluate in the log? (e.g. run "Show(name3, name4)")&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 18:43:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53952#M30481</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-03-27T18:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53956#M30484</link>
      <description>&lt;P&gt;Thanks Cameron. The name3 and name4 are listed below when show(name) is invoked.&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name3 = ":Serial# = :Serial#";
name4 = ":Red LED Hue x 64[1] = :Red LED Hue x 64[1]";
The name 3 and name4 are created by using the following script:xvar = .;
yvar = .;
win = New Window( "Choose Two Variables for Matching",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;On Validate(
// require the user to select two variables before clicking OK
		Show( xvar, yvar );
		If( Is Missing( xvar ) | Is Missing( yvar ),
			0, // if xvar or yvar are missing, do nothing when OK is clicked
			1
		);
	),
	Text Box( " Select two numeric columns. " ),
	H List Box(
		Text Box( " Choose First " ),
		x = Col List Box(
			dt1, // data table reference
			all, // display all columns from the data table
			xvar = (x &amp;lt;&amp;lt; Get Selected)[1];
// get the name of the selected column before the window closes
			Show( xvar );
		),
		Text Box( "Choose Second" ),
		y = Col List Box(
			dt2,
			all,
			yvar = (y &amp;lt;&amp;lt; Get Selected)[1];
			Show( yvar );
		)
	)
);
&amp;nbsp;
xcol = Column( dt1, xvar ); // get the columns
ycol = Column( dt2, yvar );
&amp;nbsp;
&amp;nbsp;
name1 = ":" || xvar;
name2 = ":" || yvar;
name3 = name1 || " = " || name2;
Show( name3 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p1"&gt;Similarily for name4.&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;I appreciate your help. Thanks&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 23:21:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53956#M30484</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-03-27T23:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53957#M30485</link>
      <description>&lt;P&gt;The problem is almost certainly with the square brackets in Name4.&amp;nbsp; If column names have special characters, then you cannot use the colon(:) with the column name.&amp;nbsp; You need to get the column name string wrapped in :Name().&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = ":Name(" || xvar || ")";
name2 = ":Name(" || yvar || ")";
name3 = name1 || " = " || name2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 19:30:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53957#M30485</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-03-27T19:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53966#M30490</link>
      <description>&lt;P&gt;Thanks Cameron. I modified name3 and name4 like what you suggested and I got an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;Name arg must be quoted string&lt;/P&gt;&lt;P class="p1"&gt;Line 5 Column 9: &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;:Name(►Serial#) = :Name(Serial#),&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;If I keep name3 like before, no error for Serial# but for name4. I don't know a priori what users chooses for name3 and name4.&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;Thanks for your continuous support.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 20:27:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53966#M30490</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-03-27T20:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53969#M30492</link>
      <description>&lt;P&gt;Oops, you're missing quotes inside&amp;nbsp;of name.&amp;nbsp; Forgot about that.&amp;nbsp; You can do that several ways, but here's one where we use escape syntax to insert double quotes inside of a string.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = ":Name(\!"" || xvar || "\!")";
name2 = ":Name(\!"" || yvar || "\!")";
name3 = name1 || " = " || name2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You should definitely use the :Name("col name") approach to keep this robust since you will need it to handle situations with special characters in the column names.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 22:19:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53969#M30492</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-03-27T22:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join two tables with variable names</title>
      <link>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53980#M30498</link>
      <description>&lt;P&gt;Thanks Cameron. I tried it and work fine. Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 23:38:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Join-two-tables-with-variable-names/m-p/53980#M30498</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-03-27T23:38:09Z</dc:date>
    </item>
  </channel>
</rss>

