BookmarkSubscribe
Choose Language Hide Translation Bar
kuannygoh
Occasional Contributor

Concatenate table does not show correct result

Hi all , 

I tried to concatenate several table , but the result showing "losscodereason" in multiple column , it suppose to show in one column if I do it manually in jmp.

Names Default To Here( 1 );
Final_Table="final result";
// Concatenate the tables and delete them.  Add all of the tables to the first table
dtj=data table(losscode[1]);
For( i = 2, i <= nItems(losscode), i++,
dtj << concatenate(data table(losscode[i]), append to first table(1));
	close(data table(losscode[i]), nosave);
);
// Rename the table to the desired name
dtj << set name(Final_Table);

wrong result.PNGwrong result (multiple column)correct result.PNGCorrect result (all in one column)

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User

Re: Concatenate table does not show correct result

It appears you have a table variable (top left corner frame of the data table) names lossreasonname with a value of CT.

 

In your tables, did the lossreasonname column have a formula that was based upon the table variable name?  

 

I created 3 tables Big Class, Big Class 2 and Big Class 3. Each had a column called id with a constant vale of 1, 2 and 3, respectively.  And  each had a table variable called id. If I uses this script, which is a slight modifcation of your script

Names Default To Here( 1 );
Final_Table="final result";
losscode = {"Big Class", "Big Class 2", "Big Class 3"};
// Concatenate the tables and delete them.  Add all of the tables to the first table
dtj=data table(losscode[1]);
For( i = 2, i <= nItems(losscode), i++,
dtj << concatenate(data table(losscode[i]), append to first table(1));
	//close(data table(losscode[i]), nosave);
);
// Rename the table to the desired name
dtj << set name(Final_Table);

Or even if i use the UI, I get an additional column called id2. once I get rid of the table variable name id, or for your example lossreasonname, the concatenate via the UI and via the script above works correctly.

 

I suspect the table variable with the same name as the column is messing things up.

 

1 REPLY 1
gzmorgan0
Super User

Re: Concatenate table does not show correct result

It appears you have a table variable (top left corner frame of the data table) names lossreasonname with a value of CT.

 

In your tables, did the lossreasonname column have a formula that was based upon the table variable name?  

 

I created 3 tables Big Class, Big Class 2 and Big Class 3. Each had a column called id with a constant vale of 1, 2 and 3, respectively.  And  each had a table variable called id. If I uses this script, which is a slight modifcation of your script

Names Default To Here( 1 );
Final_Table="final result";
losscode = {"Big Class", "Big Class 2", "Big Class 3"};
// Concatenate the tables and delete them.  Add all of the tables to the first table
dtj=data table(losscode[1]);
For( i = 2, i <= nItems(losscode), i++,
dtj << concatenate(data table(losscode[i]), append to first table(1));
	//close(data table(losscode[i]), nosave);
);
// Rename the table to the desired name
dtj << set name(Final_Table);

Or even if i use the UI, I get an additional column called id2. once I get rid of the table variable name id, or for your example lossreasonname, the concatenate via the UI and via the script above works correctly.

 

I suspect the table variable with the same name as the column is messing things up.