cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Kevin
Level I

join two tables different row numbers

Hello,

 

I have a question of how to merge two tables with different row numbers.

 

The first table is 

TimeTool 
182 
182 
193 
193 

 

The 2nd table is 

TimeTool 
185 
198 
   
   

 

The final Table I want is

TimeTool 
185 
185 
198 
198
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: join two tables different row numbers

Interactively, you would just run the Join platform

     Tables==>Join

and specify to match based upon Time.

Below is a script doing the same thing as the interactive actions would do

Names Default To Here( 1 );
// Create the first table
dt1 = New Table( "Table 1",
	Add Rows( 4 ),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [18, 18, 19, 19] )
	),
	New Column( "Tool",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [2, 2, 3, 3] )
	)
);
// Create the second data table
dt2 = New Table( "Untitled 10",
	Add Rows( 2 ),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [18, 19] )
	),
	New Column( "Tool",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [5, 8] )
	)
);
// Join the 2 tables
dt3 = dt1 << Join(
	With( dt2 ),
	Merge Same Name Columns,
	By Matching Columns( :Time = :Time ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);

join.PNG

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: join two tables different row numbers

Interactively, you would just run the Join platform

     Tables==>Join

and specify to match based upon Time.

Below is a script doing the same thing as the interactive actions would do

Names Default To Here( 1 );
// Create the first table
dt1 = New Table( "Table 1",
	Add Rows( 4 ),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [18, 18, 19, 19] )
	),
	New Column( "Tool",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [2, 2, 3, 3] )
	)
);
// Create the second data table
dt2 = New Table( "Untitled 10",
	Add Rows( 2 ),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [18, 19] )
	),
	New Column( "Tool",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [5, 8] )
	)
);
// Join the 2 tables
dt3 = dt1 << Join(
	With( dt2 ),
	Merge Same Name Columns,
	By Matching Columns( :Time = :Time ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);

join.PNG

Jim
Kevin
Level I

Re: join two tables different row numbers

Thank you, it works!