cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
jump
Level II

How to join\Update Multiple data tables using same Match ID

hi,

i am trying to join multiple data tables  using same match id.

update_table= Data Table( PS1(ma) " ) << Update(

  With( Data Table( "PS2(ua) ")),

  With( Data Table( "PS3(ua) ")),

With( Data Table( "PS4(ua) ")),

  Match Columns( :match_col = :match_col ),

  output table name("FINal")

);

above code only updates\joins very first table and ignores rest.

Is there a way to join\update multiple tables at same time.

Also, is there a way to use data table reference\handle to join or update tables instead of using  Data table name.

thx

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to join\Update Multiple data tables using same Match ID

Update (and Join) cannot not handle multiple tables as far as I know. I'd use a loop in this situation, for example:

tablenames = {"PS2(ua) ", "PS3(ua) ", "PS4(ua) "};

For( i = 1, i <= N Items( tables ), i++,

  Data Table( "PS1(ma) " ) << update( with( Data Table( tablenames[i] ) ) )

View solution in original post

3 REPLIES 3
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to join\Update Multiple data tables using same Match ID

Update (and Join) cannot not handle multiple tables as far as I know. I'd use a loop in this situation, for example:

tablenames = {"PS2(ua) ", "PS3(ua) ", "PS4(ua) "};

For( i = 1, i <= N Items( tables ), i++,

  Data Table( "PS1(ma) " ) << update( with( Data Table( tablenames[i] ) ) )

jump
Level II

Re: How to join\Update Multiple data tables using same Match ID

Hey MS,

thanks ..that is a good idea.

btw .. can we use table reference\handle instead of data table name. I have tried but it not working for me.

thx

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to join\Update Multiple data tables using same Match ID

Yes, it is possible. You can address a table using its name, number (e.g. Data Table(1)) or a defined variable. Below is an example using variables dt1 and dt2 that refer to data tables.

path = "$SAMPLE_DATA/"; // Path to directory of your data tables

tables = Files In Directory( path )[1 :: 3]; // Here limited to first 3 files because example dir is huge

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );

For( i = 1, i <= N Items( tables ), i++, //

  If( Ends With( tables[i], ".jmp" ), // Test that file i is a data table

  dt2 = Open( path || tables[i] );

  dt1 << update( with( dt2 ) );

  Close( dt2, no save );

  )

);