Join
Example 1
Summary: Opens a data table, joins it with another table using a Cartesian join, and prepares the data for analysis.
Code:
// Join
// Open data table
dt = Open("data_table.jmp");
// Join
Open("data_table.jmp") <<
Join(
With( Data Table("data_table") ),
Cartesian Join
);
Code Explanation:
- Open data table;
- Open data table;
- Join tables using Cartesian join.
- Specify "Batch" table for joining.
Example 2
Summary: Opens a data table, performs a Cartesian join with another data table, and enables the analysis of various ingredients and conditions on bread dough strength using linear regression.
Code:
// Cartesian join
// Open data table
dt = Open("data_table.jmp");
// Cartesian join
Open("data_table.jmp") <<
Join(
With( Data Table("data_table") ),
Cartesian Join
);
Code Explanation:
- Open data table;
- Open data table;
- Perform Cartesian join.
- Join with "data_table".
Example 3
Summary: Joins unequal rows in a data table by row number, allowing for the combination of disparate datasets.
Code:
// Joining unequal rows
// Open data table
dt = Open("data_table.jmp");
// Joining unequal rows
Open("data_table.jmp") <<
Join(
With( Data Table("data_table") ),
By Row Number
);
Code Explanation:
- Open table data_table.
- Open table data_table.
- Join tables by row number.
Example 4
Summary: Runs the merging of two data tables by matching columns and preserving main table order, generating a new output table with non-matches included.
Code:
dt1 = Open("data_table.jmp");
dt1 << set name( "data_table Dup" );
dt2 = Open("data_table.jmp");
dt3 = dt2 << Join(
With( dt1 ),
Merge Same Name Columns,
By Matching Columns( :name = :name, :age = :age ),
Drop multiples( 0, 0 ),
Name( "Include non-matches" )(0, 0),
Preserve main table order( 1 ),
Output Table( "New" )
);
tableProps = dt3 << Get Table Script Names;
Code Explanation:
- Open data table;
- Rename dataset to "data_table Dup".
- Open data table;
- Join datasets by matching columns.
- Merge same name columns.
- Drop multiple matches.
- Exclude non-matches.
- Preserve main table order.
- Output joined table as "New".
- Get table script names.
Join using Data Table
Example 1
Summary: Joins two data tables based on matching columns and preserves the original order, resulting in a new output table.
Code:
// Join
// Open data table
dt = Open("data_table.jmp");
// Join
Data Table("data_table") <<
Join(
With(
Data Table("data_table")
),
By Matching Columns(
:Date = :Date,
:Customer = :Customer,
:Beverage = :Beverage
),
Drop multiples( 1, 1 ),
"Include non-matches"n( 0, 0 ),
Preserve main table order( 1 ),
Output Table(
"data_table Final"
)
);
Code Explanation:
- Open table.
- Join tables.
- Specify matching columns.
- Drop duplicates.
- Include non-matches.
- Preserve order.
- Name output table.
Example 2
Summary: This JSL script joins two data tables, 'data_table1' and 'data_table2', using a Cartesian join method to combine their contents.
Code:
// Join
// Open data table
dt = Open("data_table1.jmp");
// Join
Data Table("data_table2") <<
Join(
With(
Open("data_table1.jmp")
),
Cartesian Join
);
Code Explanation:
- Open table "data_table1".
- Open table "data_table2".
- Join "data_table1" with "data_table2".
- Use Cartesian join method.
Example 3
Summary: Performs a Cartesian join on two data tables, allowing for the combination of variables and analysis across both datasets.
Code:
// Cartesian join
// Open data table
dt = Open("data_table.jmp");
// Cartesian join
Data Table("data_table") <<
Join(
With(
Open("data_table.jmp")
),
Cartesian Join
);
Code Explanation:
- Open data_table;
- Open data table;
- Perform Cartesian join.
- Join data_table to data_table.
Example 4
Summary: This JSL script joins two data tables by row number, allowing for the combination of unequal rows. The joined table is then created and stored in memory.
Code:
// Joining unequal rows
// Open data table
dt = Open("data_table.jmp");
// Joining unequal rows
Data Table("data_table") <<
Join(
With(
Open("data_table.jmp")
),
By Row Number
);
Code Explanation:
- Open table data_table.
- Open table data_table.
- Join tables by row number.
Join using List Check
Example 1
Summary: Runs data processing by opening a data table, performing a list check on specific names, creating a new table with additional rows and columns, joining tables based on matching names, updating the original table, and defining a renameNotify function.
Code:
dt = Open("data_table.jmp");
:name << List Check(
{"WILLIAM", "TIM", "SUSAN", "ROBERT", "PHILLIP", "PATTY", "MICHAEL", "MARY", "MARTHA", "MARK", "MARION", "LOUISE", "LINDA", "LILLIE",
"LEWIS", "LESLIE", "LAWRENCE", "KIRK", "KATIE", "JUDY", "JOHN", "JOE", "JEFFREY", "JANE", "JAMES", "JACLYN", "HENRY", "FREDERICK",
"ELIZABETH", "EDWARD", "DAVID", "DANNY", "CLAY", "CHRIS", "CAROL", "BARBARA", "AMY", "ALICE", "ALFRED"}
);
dt2 = New Table( "bc1Sub-1",
Add Rows( 5 ),
New Column( "name", Character, Nominal, Set Values( {"LOUISE", "JOHN", "LEWIS", "AMY", "LAWRENCE"} ) ),
New Column( "age", Numeric, Ordinal, Format( "Fixed Dec", 5, 0 ), Set Values( [-12, -13, -14, -15, .] ) ),
Set Label Columns( :name )
);
dtjoin = dt << Join( with( dt2 ), By Matching Columns( :name = :name ) );
Close( dtjoin, nosave );
dt << Update( With( Data Table("data_table") ), Match Columns( :name = :name ) );
Close( dt2, nosave );
Close( dt, nosave );
renameNotify = Function( {dt, oldname, newname},
Print( "renameNotify" );
Show( oldname, newname );
columnNames = dt << get column names( string );
);
Code Explanation:
- Open data table;
- List check on specific names.
- Create new table bc1Sub-1.
- Add rows and columns to bc1Sub-1.
- Join tables by matching names.
- Close joined table without saving.
- Update original table with bc1Sub-1 data.
- Close bc1Sub-1 without saving.
- Close original table without saving.
- Define renameNotify function.
Example 2
Summary: Process of joining two data tables based on matching names, creating a new table with added rows and columns.
Code:
dt = Open("data_table.jmp");
:name << List Check(
{"WILLIAM", "TIM", "SUSAN", "ROBERT", "PHILLIP", "PATTY", "MICHAEL", "MARY", "MARTHA", "MARK", "MARION", "LOUISE", "LINDA", "LILLIE",
"LEWIS", "LESLIE", "LAWRENCE", "KIRK", "KATIE", "JUDY", "JOHN", "JOE", "JEFFREY", "JANE", "JAMES", "JACLYN", "HENRY", "FREDERICK",
"ELIZABETH", "EDWARD", "DAVID", "DANNY", "CLAY", "CHRIS", "CAROL", "BARBARA", "AMY", "ALICE", "ALFRED"}
);
dt2 = New Table( "bc1Sub-1",
Add Rows( 5 ),
New Column( "name", Character, Nominal, Set Values( {"LOUISE", "JOHN", "LEWIS", "AMY", "LAWRENCE"} ) ),
New Column( "age", Numeric, Ordinal, Format( "Fixed Dec", 5, 0 ), Set Values( [-12, -13, -14, -15, .] ) ),
Set Label Columns( :name )
);
dtjoin = dt << Join( with( dt2 ), By Matching Columns( :name = :name ) );
Code Explanation:
- Open data table.
- Check names against list.
- Create new data table.
- Add five rows to new table.
- Add name column with values.
- Add age column with values.
- Set label columns for name.
- Join tables by matching names.
Join using Run Script
Summary: Creates and manipulates data tables, vectors, and path diagrams in JMP, utilizing various scripting commands to perform tasks such as data compression, column selection, and diagram customization.
Code:
dt = Open("data_table.jmp");
obj = dt << Run Script( "Bivariate" );
dt << Select Where( :sex == "F" );
dt << Colors( "Red" );
rs = dt << Get row states;
Close( dt, nosave );
dt = New Table( "Data1",
New Column( "ID", Character, Values( {"AAAA", "BBBB", "CCCCCC", "DDDDDDDD", "EEEEEEEEEEE", "FFFF", "GGG", "H", "I", "J", "K"} ) ),
New Column( "Y", Values( J( 11, 1, -10000 ) ) )
);
dt << Compress Selected Columns( {:ID} );
lnth = dt:ID << Get Data Type Length( English );
dt2 = New Table( "Data2", New Column( "ID", Character, Values( {"J", "K"} ) ), New Column( "Y", Values( [9999, 9999] ) ) );
newjoin = dt << Join( With( dt2 ), Update, By Matching Columns( :ID = :ID ), Include Nonmatches( 1, 0 ) );
vals = newjoin:ID << get values;
Close( newjoin, nosave );
Close( dt2, nosave );
Close( dt, nosave );
dt = New Table( "Vectors", <<New Column( "Vec", vector ) );
dt1 = New Table( "Vectors", <<New Column( "Vec", vector ) );
For( i = 1, i <= 20, i++,
dt1 << add rows( 1 );
dt1:vec = J( 5, 1, Random Integer( 10 ) );
);
vecs = {};
For( i = 1, i <= 20, i++,
Insert Into( vecs, Eval List( {J( 5, 1, Random Integer( 20 ) )} ) )
);
dt2 = New Table( "Vectors", <<New Column( "Vec", vector, <<set values( vecs ) ) );
Close( dt, nosave );
Code Explanation:
- Open data table.
- Run Bivariate script on table.
- Select female entries.
- Change selected rows color to red.
- Get row states.
- Close original data table without saving.
- Create new data table "Data1".
- Compress ID column in "Data1".
- Get data type length of ID column.
- Create and join "Data2" with "Data1".
- Retrieve values from joined table.
- Close joined and "Data2" tables without saving.
- Create new "Vectors" table.
- Add 20 rows with random integer vectors to "Vectors".
- Create another "Vectors" table.
- Insert random integer vectors into list.
- Set values of "Vectors" table to list.
- Close final "Vectors" table without saving.
Join using Set Table Variable
Summary: Process of opening two data tables, setting a table variable, creating a new column with a formula, and joining the tables based on matching columns.
Code:
dt = Open("data_table.jmp");
dt2 = Open("data_table.jmp");
dt2 << Set Table Variable( "x", 20 );
dt2 << New Column( "test", Numeric, "Continuous", Format( "Best", 12 ), Formula( :x ) );
joindt = Data Table("data_table") << Join(
With( Data Table("data_table") ),
Merge Same Name Columns,
Suppress formula evaluation( 0 ),
Select( :popcorn, :oil, :batch, :yield, :test ),
By Matching Columns( :popcorn = :popcorn, :oil = :oil amt, :batch = :batch ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 )
);
Code Explanation:
- Open data table 1;
- Open data table 2;
- Set table variable "x" to 20.
- Create new column "test" in dt2.
- Define formula for "test" as :x.
- Join "data_table1" with "data_table2".
- Merge same name columns.
- Suppress formula evaluation.
- Select specific columns for join.
- Match columns by name and values.
Join using Value Labels
Summary: Runs the joining and labeling of two data tables based on matching columns, while preserving main table order and excluding nonmatches.
Code:
dt1 = Open("data_table.jmp");
dt2 = Open("data_table.jmp");
dt1:oil << Value Labels( {"little" = "b"} );
dt2:oil amt << Value Labels( {"little" = "b", "lots" = "a"} );
newtab4 = dt1 << Join(
With( Data Table( dt2 ) ),
By Matching Columns( :oil = :oil amt ),
Drop multiples( 1, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 )
);
col3 = Column( newtab4, "Popcorn of trial1" );
Code Explanation:
- Open data table;
- Open data table;
- Label "little" as "b" in oil.
- Label "little" as "b" and "lots" as "a" in oil amt.
- Join tables by matching columns.
- Drop multiple matches.
- Exclude nonmatches.
- Preserve main table order.
- Assign "Popcorn of trial1" to col3.
Join using Add Rows
Summary: Runs the merging and joining of two data tables, adding new rows to the second table and matching by name columns.
Code:
dt = Open("data_table.jmp");
dt3 = Open("data_table.jmp");
dt3 << Add Rows( 2 );
dt3:name[41] = "PENELOPE";
dt3:name[42] = "GEORGE";
dt3:height[41] = 69;
dt3:height[42] = 75;
joinDt3 = dt << Join(
With( dt3 ),
Merge Same Name Columns,
By Matching Columns( :name = :name ),
Drop multiples( 1, 1 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )
);
Code Explanation:
- Open data table;
- Open data table;
- Add 2 rows to New Heights.
- Set name for row 41 to PENELOPE.
- Set name for row 42 to GEORGE.
- Set height for row 41 to 69.
- Set height for row 42 to 75.
- Join data_table with New Heights.
- Merge columns with same name.
- Match by name column.