cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
switzal87
Level III

Concatenate output tables from a Loop

Hello JMP community!

 

I had these 5 tables coming from a loop. Below is the screenshot of the script (Assuming its working fine)

 

Loop.JPG

How should I write a script that concatenates all the output table of the loop?!

Appreciate all inputs from this community!

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
julian
Community Manager Community Manager

Re: Concatenate output tables from a Loop

Hi @switzal87,

 

The following will concatenate the last 5 tables opened:

Data Table(N Table()) << Concatenate(
	Data Table( N Table()-1 ),
	Data Table( N Table()-2 ),
	Data Table( N Table()-3 ),
	Data Table( N Table()-4 ),
	Create source column
);

This works because Data Table(number) refers to a specific table, N Table() returns the number of data tables open in JMP, data tables are numbered based on when they are opened, thus Data Table(N Table()) returns the last table, and subtracting k from N Table() returns the table opened k tables ago. You could generalize this by writing a loop to generate the concatenation code, but if you're always pulling 5 tables this is a pretty easy way to combine them. 

 

I hope this helps!

 

@julian

 

edit: Here is a generalized version for any number of tables:

tableList={};

for(k=1,k<=4,k++,InsertInto(tableList,Data Table( N Table()-k )));

Data Table(N Table()) << Concatenate(tableList,Create source column);

View solution in original post

1 REPLY 1
julian
Community Manager Community Manager

Re: Concatenate output tables from a Loop

Hi @switzal87,

 

The following will concatenate the last 5 tables opened:

Data Table(N Table()) << Concatenate(
	Data Table( N Table()-1 ),
	Data Table( N Table()-2 ),
	Data Table( N Table()-3 ),
	Data Table( N Table()-4 ),
	Create source column
);

This works because Data Table(number) refers to a specific table, N Table() returns the number of data tables open in JMP, data tables are numbered based on when they are opened, thus Data Table(N Table()) returns the last table, and subtracting k from N Table() returns the table opened k tables ago. You could generalize this by writing a loop to generate the concatenation code, but if you're always pulling 5 tables this is a pretty easy way to combine them. 

 

I hope this helps!

 

@julian

 

edit: Here is a generalized version for any number of tables:

tableList={};

for(k=1,k<=4,k++,InsertInto(tableList,Data Table( N Table()-k )));

Data Table(N Table()) << Concatenate(tableList,Create source column);