Hi All,
This may be starighfroward but I am not able to get the right JSL commands.
I really appreciate if anyone could help me.
I am running a FOR loop and every time I run it, I open a data table.
I want to concatenate all data tables together and save it as FINAL TABLE.
Thanks.
@vishwasanj :
Please use the following code to fix your problem .
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
n = 5 ; // Random # of iterations
for (i = 1 , i <= n , i++,
RowsToSelect = Random Index(40,5);
dt << Select Rows(RowsToSelect);
dt << Subset("");
);
// In your case data is coming from a file
// So I am closing out the source table here that I opened for the purpose of demonstration
Close(dt,"No Save");
// Make a list of all open Data tables
openDTs = List();
For( i = 1, i <= N Table(), i++,
Insert Into( openDTs, Data Table( i ) );
);
// Concatenate
for(i = 1 ,i <= N Table(), i++,
dt_Results = openDTs[i];
//Close(openDTs[i]);
,
dt_Results << Concatenate(openDTs[i],"Append To First Table");
Close(openDTs[i]);
);
dt_Results << Set Name("Results");
@vishwasanj :
Hello . I think this can be done through the following piece of code .
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
n = 5 ; // Random # of iterations
for (i = 1 , i <= n , i++,
RowsToSelect = Random Index(40,5);
dt << Select Rows(RowsToSelect);
dt1 = dt << Subset("");
If(i == 1,
dt_Results = dt1 ;
,
dt_Results << Concatenate(dt1,"Append To First Table");
Close(dt1,"No Save");
);
);
Just to explain what is going on here :
- Once you open the loop - we are randomly choosing which rows to select to generate a sample set - here
RowsToSelect = Random Index(40,5);
dt << Select Rows(RowsToSelect); dt1 = dt << Subset("");
- At i = 1 , you are initializing the format of the output data table that defines your results
- When i != 1 , you are concatenating data from the newly formed table back to the template file
Best
uday
@vishwasanj :
Please use the following code to fix your problem .
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
n = 5 ; // Random # of iterations
for (i = 1 , i <= n , i++,
RowsToSelect = Random Index(40,5);
dt << Select Rows(RowsToSelect);
dt << Subset("");
);
// In your case data is coming from a file
// So I am closing out the source table here that I opened for the purpose of demonstration
Close(dt,"No Save");
// Make a list of all open Data tables
openDTs = List();
For( i = 1, i <= N Table(), i++,
Insert Into( openDTs, Data Table( i ) );
);
// Concatenate
for(i = 1 ,i <= N Table(), i++,
dt_Results = openDTs[i];
//Close(openDTs[i]);
,
dt_Results << Concatenate(openDTs[i],"Append To First Table");
Close(openDTs[i]);
);
dt_Results << Set Name("Results");