<?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 Issue with concatenating and sort function in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Issue-with-concatenating-and-sort-function/m-p/826492#M100752</link>
    <description>&lt;P&gt;I'm creating a table called "combinedTable" by concatenating two files and it saves just fine. But I would like to sort the concatenated table, but when I use the sort function it creates a new untitled table that pops up while saving the unsorted "combinedTable". What's wrong with my script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;....&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;extractLast9Chars = Function({filename}, 

	Substr(filename, Length(filename) - 12, 11)
);

// Create a dictionary to store files by their last 9 characters
fileDict = Associative Array();

// Populate the dictionary with files from the first folder
For(i = 1, i &amp;lt;= N Items(files1), i++,
	last9 = extractLast9Chars(files1[i]);
	fileDict[last9] = folder1 || "/" || files1[i];
);


// Check for matching files in the second folder and combine them
For(j = 1, j &amp;lt;= N Items(files2), j++,
	last9 = extractLast9Chars(files2[j]);
	If(Contains(fileDict, last9), 
// Open the files
		file1 = Open(fileDict[last9]);
		file2 = Open(folder2 || "/" || files2[j]);

// Combine the data tables
		combinedTable = Concatenate(file1, file2);
		combinedTable &amp;lt;&amp;lt; select where(Col Min(Row(), :lot, :wfr, :site) &amp;lt; Row()) &amp;lt;&amp;lt; delete rows;
		combinedTable &amp;lt;&amp;lt; sort(By(:wfr, :Site));


//save table with new name in existing foler
		newTableName = files2[j] || "_combined";
		filePath = "C:\temp\66k_Combined\" || newTableName;
		combinedTable &amp;lt;&amp;lt; save(filePath);

// Close the individual files
		Close(file1, NoSave);
		Close(file2, NoSave);
		Close(combinedTable, NoSave);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2025 20:10:00 GMT</pubDate>
    <dc:creator>CoxPorcupine721</dc:creator>
    <dc:date>2025-01-09T20:10:00Z</dc:date>
    <item>
      <title>Issue with concatenating and sort function</title>
      <link>https://community.jmp.com/t5/Discussions/Issue-with-concatenating-and-sort-function/m-p/826492#M100752</link>
      <description>&lt;P&gt;I'm creating a table called "combinedTable" by concatenating two files and it saves just fine. But I would like to sort the concatenated table, but when I use the sort function it creates a new untitled table that pops up while saving the unsorted "combinedTable". What's wrong with my script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;....&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;extractLast9Chars = Function({filename}, 

	Substr(filename, Length(filename) - 12, 11)
);

// Create a dictionary to store files by their last 9 characters
fileDict = Associative Array();

// Populate the dictionary with files from the first folder
For(i = 1, i &amp;lt;= N Items(files1), i++,
	last9 = extractLast9Chars(files1[i]);
	fileDict[last9] = folder1 || "/" || files1[i];
);


// Check for matching files in the second folder and combine them
For(j = 1, j &amp;lt;= N Items(files2), j++,
	last9 = extractLast9Chars(files2[j]);
	If(Contains(fileDict, last9), 
// Open the files
		file1 = Open(fileDict[last9]);
		file2 = Open(folder2 || "/" || files2[j]);

// Combine the data tables
		combinedTable = Concatenate(file1, file2);
		combinedTable &amp;lt;&amp;lt; select where(Col Min(Row(), :lot, :wfr, :site) &amp;lt; Row()) &amp;lt;&amp;lt; delete rows;
		combinedTable &amp;lt;&amp;lt; sort(By(:wfr, :Site));


//save table with new name in existing foler
		newTableName = files2[j] || "_combined";
		filePath = "C:\temp\66k_Combined\" || newTableName;
		combinedTable &amp;lt;&amp;lt; save(filePath);

// Close the individual files
		Close(file1, NoSave);
		Close(file2, NoSave);
		Close(combinedTable, NoSave);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 20:10:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Issue-with-concatenating-and-sort-function/m-p/826492#M100752</guid>
      <dc:creator>CoxPorcupine721</dc:creator>
      <dc:date>2025-01-09T20:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with concatenating and sort function</title>
      <link>https://community.jmp.com/t5/Discussions/Issue-with-concatenating-and-sort-function/m-p/826504#M100753</link>
      <description>&lt;P&gt;You are missing replace table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1736453476580.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71764iF5F9390C4134E9DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1736453476580.png" alt="jthi_0-1736453476580.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do sort in JMP table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1736453495023.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71765i96E5AC66FA88F380/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1736453495023.png" alt="jthi_1-1736453495023.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can see what JMP does from enhanced log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Sort data table
Data Table("Big Class") &amp;lt;&amp;lt; Sort(By(:height), Replace Table, Order(Ascending));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jan 2025 20:12:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Issue-with-concatenating-and-sort-function/m-p/826504#M100753</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-09T20:12:12Z</dc:date>
    </item>
  </channel>
</rss>

