- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
concatenate data tables on the go
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: concatenate data tables on the go
@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");
Uday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: concatenate data tables on the go
@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"); ); );
Uday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: concatenate data tables on the go
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
Uday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: concatenate data tables on the go
I hope I didn't over-complicate it. Let me know your thoughts. I will see how I can modify your script. Thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: concatenate data tables on the go
@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");
Uday