- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to supply argument to delimiter in combine columns ()?
The following does not work
Names Default To Here (1);
// Combine columns
dm = ".0";
Data Table( "myTable" ) << Combine Columns(
columns( :Col1, :Col2 ),
Column Name( "ID" ),
Delimiter(dm)
//Delimiter ("dm")
);
But writing the argument to Delimiter directly as
Delimiter(".0")
works. How to supply argument to the delimiter from outside?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to supply argument to delimiter in combine columns ()?
The Combine Columns message is doing the same as Cols > Utilities > Combine Columns.
Combine Columns doesn't support any conditionalizing.
Instead, I'd create a new column with a formula to concatenate your other columns as you desire.
Here's what the formula would look like in the Formula Editor.
And here's the JSL to create it.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm1 = ":";
dm2 = "-";
Eval(
Substitute(
Expr(
dt << New Column( "ID",
Character,
"Nominal",
Formula( :name || If( :age <= 13, d1, d2 ) || Char( :age ) ),
)
),
Expr( d1 ), dm1,
Expr( d2 ), dm2
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to supply argument to delimiter in combine columns ()?
This happens because JMP doesn't evaluate arguments to arguments in messages.
You can use Substitute to substitute in the value of dm.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm = ":";
Eval(
Substitute(
Expr(
dt << Combine Columns(
columns( :name, :age ),
Column Name( "ID" ),
Delimiter( d )
)
),
Expr( d ), dm
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to supply argument to delimiter in combine columns ()?
@Jeff_Perkinson Thanks. In this case, how to script, if I have a condition on the delimiter - e.g. delimiter = ".0" if : age <13 and delimiter = ".1", otherwise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to supply argument to delimiter in combine columns ()?
The Combine Columns message is doing the same as Cols > Utilities > Combine Columns.
Combine Columns doesn't support any conditionalizing.
Instead, I'd create a new column with a formula to concatenate your other columns as you desire.
Here's what the formula would look like in the Formula Editor.
And here's the JSL to create it.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm1 = ":";
dm2 = "-";
Eval(
Substitute(
Expr(
dt << New Column( "ID",
Character,
"Nominal",
Formula( :name || If( :age <= 13, d1, d2 ) || Char( :age ) ),
)
),
Expr( d1 ), dm1,
Expr( d2 ), dm2
)
);