Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- concatenate data tables on the go

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Sep 14, 2017 2:43 PM
(5475 views)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@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");

Best

Uday

Uday

4 REPLIES 4

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- 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"); ); );

Best

Uday

Uday

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- 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

Best

Uday

Uday

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: concatenate data tables on the go

Thank you Uday. I think I get an idea of how to do it. But what I have is, I run the loop and it creates a new data table every time it completes. I don't have a control on the count or choice of the file, because it is created automatically. I could have 2, or 5, or 9 data tables at the end of the loop opened. I wanted to concatenate all into one table.

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.

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.

- Tags:
- @uday_guntupalli

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@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");

Best

Uday

Uday