cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Issue with concatenating and sort function

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?

 

<....

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 <= 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 <= 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 << select where(Col Min(Row(), :lot, :wfr, :site) < Row()) << delete rows;
		combinedTable << sort(By(:wfr, :Site));


//save table with new name in existing foler
		newTableName = files2[j] || "_combined";
		filePath = "C:\temp\66k_Combined\" || newTableName;
		combinedTable << save(filePath);

// Close the individual files
		Close(file1, NoSave);
		Close(file2, NoSave);
		Close(combinedTable, NoSave);
	);
);

>

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Issue with concatenating and sort function

You are missing replace table

jthi_0-1736453476580.png

 

If you do sort in JMP table

jthi_1-1736453495023.png

You can see what JMP does from enhanced log

// Sort data table
Data Table("Big Class") << Sort(By(:height), Replace Table, Order(Ascending));
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Issue with concatenating and sort function

You are missing replace table

jthi_0-1736453476580.png

 

If you do sort in JMP table

jthi_1-1736453495023.png

You can see what JMP does from enhanced log

// Sort data table
Data Table("Big Class") << Sort(By(:height), Replace Table, Order(Ascending));
-Jarmo

Recommended Articles